hibernate解决延迟加载 [main] ERROR org.hibernate.LazyInitializationException - could n



[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;


你可能感兴趣的:(java,Hibernate)