• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

fetching Child objects

 
chandra mohan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am not that much familiar with hibernate.I had a Adversion table. In adversion mapping file I had specified lazy ="false" for 6 properties.
I am trying to retrive the Adversion object using primary key.



It is loading all the child objects.
I just want to load only one of the child object out of 6 eventhough lazy property is set in hbm file.

How to do this ?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have defined lazy loading as false in your mapping you can't override this in code. When you get one object, you always get whatever is associated where the association is defined with lazy=false.

You can do this the other way round though. Set lazy=true and "eagerly fetch" results from your query when you want to. When you don't, nothing extra will come back.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic