by using a different key-column?

<class name="Parent">
   <set name="Children1" inverse="true" cascade="all-delete-orphan">
       <key column="parent_id_1"/>
       <one-to-many class="Child"/>
   </set>
   <set name="Children2" inverse="true" cascade="all-delete-orphan">
       <key column="parent_id_2"/>
       <one-to-many class="Child"/>
   </set>
</class>

<class name="Child">
   <many-to-one name="Parent1" column="parent_id_1" not-null="true"/>
   <many-to-one name="Parent2" column="parent_id_2" not-null="true"/>
</class>

Show a real world domain, where you need this.

2010/9/9 v64 <[email protected]>

> Hi,
>
> My parent class has two collection properties that hold entities of
> the same type. I'm trying to understand the correct way to map this.
> Using the example from the docs:
>
> <class name="Parent">
>    <set name="Children1" inverse="true" cascade="all-delete-orphan">
>        <key column="parent_id"/>
>        <one-to-many class="Child"/>
>    </set>
>    <set name="Children2" inverse="true" cascade="all-delete-orphan">
>        <key column="parent_id"/>
>        <one-to-many class="Child"/>
>    </set>
> </class>
>
> <class name="Child">
>    <many-to-one name="Parent" column="parent_id" not-null="true"/>
> </class>
>
> This obviously will not work because there's no way to tell which
> parent collection a child belongs to. How do I map this?
>
> TIA
> v64
>
>
> --
> 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]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>

-- 
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