----------------------------------------------------------------------------------------------------------------------------------------------- 本文提示:《解释一个关于Hibernate lazy的问题(3)》是本站编辑们为广大网友精选的实用文章,本文阐述了关于文章的相关理论,相对来说专业性强,但是本文只是针对于某个问题提出的见解与论述,未必能辐射到相关问题的方方面面,所以本文处理问题的方法仅仅为您提供一些参考。更多问题请查阅学习中国网其他栏目哦. -----------------------------------------------------------------------------------------------------------------------------------------------
public TSysuser getUser(int userid) {
if (this.getHibernateTemplate() == null) {
System.out.println("error at there");
return null;
}
TSysuser edituser= (TSysuser) getHibernateTemplate().load(TSysuser.class, new Integer(userid));
System.out.println(edituser.getUsername());
System.out.println(edituser.getDeptno());
return edituser;
}
如果删除上面的
java代码:
System.out.println(edituser.getUsername());
System.out.println(edituser.getDeptno());
在点击编号,修改时候就会出现错误:
2005-10-27 15:35:59,245 ERROR [org.hibernate.LazyInitializationException] - could not initialize proxy - the owning Session was closed
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
经过在javaeye论坛大家一致认为 是hibernate lazy的原因
在WEB级别应用时候,会出现意想不到的lazy错误,解决方法就是 设置 lazy="false" 例:
<hibernate-mapping>
<class name="com.jeedev.hb.TSysuser" table="t_sysuser" lazy="false">
本文章更多内容:<<上一页 - 1 - 2 - 3 |