"The gotcha for me here is that CreditCardPayment and WirePayment can potentially have the same IDs since they are in different tables, so I need some way to tell NHibernate to take the PaymentType into consideration." only if 1. your domain model allows multiple payments types per order 2. you modify the data outside of the domain model
if 1 then you would have a collection of payments, not a single payment per order. if #2, then you need to be careful of how you alter the data. and consider why you are not using the domain model. the other option is to think about the context of payment. does a payment make sense without an order? if no, then Payment doesn't need an association to Order, only Order to Payment. if you are processing and reporting from a single domain model/database then you may want a bidirectional association. On Oct 4, 3:36 pm, David McClelland <[email protected]> wrote: > Ayende has a great example of using the <any> mapping > athttp://ayende.com/Blog/archive/2009/04/21/nhibernate-mapping-ltanygt...., > which I am reposting as part of my question since comments are closed > on that blog post > > Given his original mapping: > > <class name="Order" table="Orders"> > <id name="Id"> > <generator class="native"/> > </id> > <any name="Payment" id-type="System.Int64" meta- > type="System.String" cascade="all"> > <meta-value value="CreditCard" class="CreditCardPayment"/> > <meta-value value="Wire" class="WirePayment"/> > <column name="PaymentType"/> > <column name="PaymentId"/> > </any> > </class> > > <class name="CreditCardPayment" table="CreditCardPayments"> > <id name="Id"> > <generator class="native"/> > </id> > <property name="IsSuccessful"/> > <property name="Amount"/> > <property name="CardNumber"/> > </class> > > <class name="WirePayment" table="WirePayments"> > <id name="Id"> > <generator class="native"/> > </id> > <property name="IsSuccessful"/> > <property name="Amount"/> > <property name="BankAccountNumber"/> > </class> > > ... how would I go about mapping a property named Order on the > CreditCardPayment and WirePayment classes which would be the "flip > side" of the association allowing traversal from these payments back > up to the Order they are associated with? > > The gotcha for me here is that CreditCardPayment and WirePayment can > potentially have the same IDs since they are in different tables, so I > need some way to tell NHibernate to take the PaymentType into > consideration. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
