hibernate.enable_lazy_load_no_trans is not working

前端 未结 2 971
醉话见心
醉话见心 2021-01-22 10:47

I\'m using JPA2.1 and hibernate 4.3.8 and i have configured the presistence.xml to allow lazy loading

i have added



        
相关标签:
2条回答
  • 2021-01-22 10:55

    The hibernate.enable_lazy_load_no_trans is an anti-pattern and you should never use it because a database connection is needed for every lazy association that is fetched outside of the initial Persistence Context, and that's going to put pressure on the underlying transaction log and the JDBC connection pool.

    More, the hibernate.enable_lazy_load_no_trans is prone to N+1 query issues.

    Sometimes, you don't even need entities, and a DTO projection is even better.

    0 讨论(0)
  • 2021-01-22 11:14

    Try enter the "true" like this:

    <property name="hibernate.enable_lazy_load_no_trans">true</property>

    It work for me.

    0 讨论(0)
提交回复
热议问题