What is Lazy Loading ?

Lazy loading decides whether to load the child objects while loading the parent object.


we need to do this setting in Hibernate mapping files(hbm.xml) of parent class


lazy =true ,(means not to load child object).  Default value is true,


This make sure that the child objects are not loaded unless they are explicitly invoked in application by calling getChild() method on parent.
In this case hibernate issues a fresh Database call to load the child objects when getChild() method actually called on the parent object.


but some cases we need to load the child objects when parent is loaded, just make the lazy=false
this is called Agressive Loading.
i.e Hibernate will  load the child object when parent is loaded from the database.

0 comments :

Post a Comment