hibernate解决延迟加载 [main] ERROR org.hibernate.LazyInitializationException - could n
程序员文章站
2022-03-02 14:14:07
...
[main] ERROR org.hibernate.LazyInitializationException - could not initialize proxy - no Session
public Users findById(Long id){
Session session =HibernateSessionFactory.getSession();
Transaction trans = session.beginTransaction();
Users users = (Users)session.load(com.zyl.hiber.po.Users.class, id);
if(!Hibernate.isInitialized(users))Hibernate.initialize(users);
trans.commit();
session.close();
return users;
上一篇: 解决idea JSP路径错误问题