org.hibernate.LazyInitializationException: could not initialize proxy - no Session

前端 未结 4 492
慢半拍i
慢半拍i 2020-12-31 12:17

I have 2 physical servers which my web application hits managed by load balancers. I always get -

org.hibernate.LazyInitializationException: could not initia

4条回答
  •  长发绾君心
    2020-12-31 12:37

    From the tags you provided, I deduce you ran into this problem using Spring Framework. I ran into the same LazyInitializationException while using a Spring Data org.springframework.data.jpa.repository.JpaRepository.

    I solved the problem by annotating the method which indirectly uses Hibernate to retrieve data from the database with @Transactional.

提交回复
热议问题