Ayende has a great example of using the <any> mapping at
http://ayende.com/Blog/archive/2009/04/21/nhibernate-mapping-ltanygt.aspx,
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.

Reply via email to