Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How does Hibernate get child objects

 
Himadri Das
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi , I have very recently started using Hibernate JPA and have some basic doubts.

How does hibernate get child records . This is my understanding , please correct me if am wrong.

For Eg , parent has two child . if I query parent , I get the childs also if fetchType = Eager. Its true for vice versa also.

Suppose , the query comes from child , child 1 to get its parent. and another child 2 has also requested the same parent. During loading of child 2 queried , will hibernate created an object of parent in memory or use the one already loaded by child 1 ?

What is lazy loading ?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

For Eg , parent has two child . if I query parent , I get the childs also if fetchType = Eager. Its true for vice versa also.

Yes.

lazy loading is the behaviour whereby associated objects are loaded only when they are requested. The trigger to load the associated object is asking for a property of the associated object from the parent, e.g.:

[ June 03, 2008: Message edited by: Paul Sturrock ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic