求助,关闭错误!
代码如下:String sql = "from StudentInfo where studentId=1";
List list = template.find(sql);
if (list != null) {
for(int i=0;i<list.size();i++)
{
StudentInfo stus = (StudentInfo)list.get(i);
System.out.println(stus.getUsers().getUserName() + " "
+ stus.getRemark() + " "
+ stus.getPersonInfo().getNameSpell());
}
}
错误信息如下:
2007-05-12 10:11:59,268 [http8080-Processor25] 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
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:56)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:98)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:158)
at com.yyaccp.edu.model.strive.Users$$EnhancerByCGLIB$$2c251792.getUserName(<generated>)
at com.yyaccp.edu.dataaccess.strive.StudentInfoImpl.findAllStudent(StudentInfoImpl.java:58)
at com.yyaccp.edu.business.strive.StudentInfoBizImpl.findAllStudent(StudentInfoBizImpl.java:21)
template已经配置好了,我在另一个方法里面使用了
58行就是上面我用红色标记出来的那行