• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to retrieve the value from grand Child in Hibernate

 
Veeresh Hosur
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a table called Parent which has one to many relataion with another table CHILD. This CHILD table has one to one relation with GRANDCHILD. I have used generic names to make my problem more clear.

I have a set defined in child.hbm.xml to fetch grandchild

<set name="GrandChildren" inverse="false">
<key>
<column name="ID" precision="12" scale="0" />
<column name="ORD_ID" precision="12" scale="0" />
</key>
<one-to-many class="com.myapp.GrandChild" />
</set>

wheneven i do

Parent parents = getsession.CreateCriteria(Parent.class).add(Restriction.eq("id",ParentId)).uniqueResult();

Set<Child>childrenSet = parents.getChildren();

the children set is populated but the GrandChildren set that i have mapped in CHILD.hbm.xml as i mentioned above is not at all populated.

If i use the hibernate query that i will get in console in SQl Client i was able to see the records for that particular query.

Please help on this
 
maheswara reddy
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Veeresh , ru you still looking for this solution ? If you have please post it

Regards,
MAhesh
Veeresh Hosur wrote:I have a table called Parent which has one to many relataion with another table CHILD. This CHILD table has one to one relation with GRANDCHILD. I have used generic names to make my problem more clear.

I have a set defined in child.hbm.xml to fetch grandchild

<set name="GrandChildren" inverse="false">
<key>
<column name="ID" precision="12" scale="0" />
<column name="ORD_ID" precision="12" scale="0" />
</key>
<one-to-many class="com.myapp.GrandChild" />
</set>

wheneven i do

Parent parents = getsession.CreateCriteria(Parent.class).add(Restriction.eq("id",ParentId)).uniqueResult();

Set<Child>childrenSet = parents.getChildren();

the children set is populated but the GrandChildren set that i have mapped in CHILD.hbm.xml as i mentioned above is not at all populated.

If i use the hibernate query that i will get in console in SQl Client i was able to see the records for that particular query.

Please help on this
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic