Obviously with "add child" you mean add it to the collection of children and
assign the Parent property, no ?

2010/1/25 Lakshman <[email protected]>

> All,
>
> I am having some trouble getting the children from the self reference
> table.
>
> Here is the configuration that I use:
>
> <?xml version="1.0" encoding="utf-8"?>
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
>    <class
> name="BusinessEntities.TestDB.Person,BusinessEntities.TestDB"
> table="Person" lazy="true" dynamic-insert="true" dynamic-
> update="true">
>    <id name="PersonId" column="PersonId" type="int">
>      <generator class="native" />
>    </id>
>           <property type="int" not-null="true" name="Ssn" column="`SSN`" />
>    <property type="string" length="10" name="FirstName"
> column="`FirstName`" />
>    <property type="string" not-null="true" length="10"
> name="LastName" column="`LastName`" />
>          <bag name="Children" inverse="true" lazy="true"
> cascade="all-delete-
> orphan">
>                  <key column="ParentId" />
>                  <one-to-many
> class="BusinessEntities.TestDB.Person,BusinessEntities.TestDB" />
>          </bag>
>          <many-to-one name="Parent"
> class="BusinessEntities.TestDB.Person,BusinessEntities.TestDB">
>                  <column name="ParentId" />
>          </many-to-one>
>  </class>
> </hibernate-mapping>
>
> I can add a parent object and a child object successfully. But, If I
> try to access the collection 'Children' from the parent object, it is
> null. Also, I don't see any SQL queries related to that in the log
> files.
>
> Please let me know what is missing. Appreciate your help.
>
> Thanks,
> Lakshman
>
> --
> 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.
>
>


-- 
Fabio Maulo

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