Correction:

class Parent
{
    public List<Child> first;
    public List<Child> second;
}


class Child
{
    public Parent parent;
}

On Sep 10, 11:10 am, v64 <[email protected]> wrote:
> I need the child to be parented through one of several properties on
> the same parent. A child still has a single parent, but the system
> needs to distinguish which property on the parent points to a
> particular child instance.
>
> Unfortunately I cannot give a real world domain example. We are
> building a dynamic model where the customer would be able to define
> the entities and their relationships and we dinamically generate the
> mapping (and the db schema) based on the customer model. The scenario
> that I described looks like a valid object model, and we need to
> support it. This is what it would look like in terms of classes:
>
> class Parent
> {
>     public Child first;
>     public Child second;
>
> }
>
> class Child
> {
>     public Parent parent;
>
> }
>
> Thanks,
> v64
>
> On Sep 9, 6:28 pm, José F. Romaniello <[email protected]> wrote:
>
>
>
> > 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.-Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

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