The lazy attribute for property tag in hibernate allows to lazily load the property as per the link: http://docs.jboss.org/hibernate/orm/3.3/reference/en-US/html/mapping.htm
Lazy loading you have used
is not right way of using it, because title is not associated with other objects. If it is used in your relationship mapping
then it will give you some performance boost.
In the above configuration. If lazy="false"
: - when you load the Event object that time child object Person is also loaded and set to setPerson() method. If you call evet.getPerson()
then loaded data returns. No fresh database call.
If lazy="true"
:- This the default configuration. If you don't mention then hibernate consider lazy=true
. when you load the Event
object that time child object Person is not loaded. You need extra call to data base to get address objects. If you call event.getPerson()
then that time database query fires and return results. Fresh database call.
To test once set it false
and then see your output query