Spring, @Transactional and Hibernate Lazy Loading

前端 未结 3 1884
孤独总比滥情好
孤独总比滥情好 2021-02-04 10:16

i\'m using spring + hibernate. All my HibernateDAO use directly sessionFactory.

I have application layer -> service layer -> DAO layer and all collections is lazly loade

3条回答
  •  抹茶落季
    2021-02-04 11:00

    1. Create a method in the service layer that returns the lazy-loaded object for that entity
    2. Change to fetch eager :)
    3. If possible extend your transaction into the application layer

    (just while we wait for someone who knows what they are talking about)

提交回复
热议问题