Hibernate could not initialize proxy - no Session

后端 未结 3 1665
小鲜肉
小鲜肉 2021-02-13 13:14

My code retrieves all information related to the user:

SessionFactory sessionFactory = HibernateUtilities.configureSessionFactory();
Session session = sessionFac         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-13 13:30

    userAddress = ud.getAddresses();
    session.getTransaction().commit();
    for(Address addr: userAddress) {
    

    The hibernate documentation for working with lazy associations clearly calls out this kind of access as an error. You can interact with lazily associated objects only while the session is still open. That portion of the documentation also provides alternatives to access such lazily associated members of an object and we prefer to specify the fetch mode as JOIN in the criteria used, in our applications.

提交回复
热议问题