Using lazy for properties in Hibernate

前端 未结 3 1338
一个人的身影
一个人的身影 2021-01-03 05:41

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

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-03 06:19

    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

提交回复
热议问题