早教吧 育儿知识 作业答案 考试题库 百科 知识分享

com.accp.dao.impl.StudentsDAOImpl@1ba92dbHibernate:selecttop2students0.idasid0,students0.classidasclass20,students0.nameasname0,students0.ageasage0fromstudentsstudents0orderbystudents0.iddescHibernate:selectcount(*)as

题目详情
com.accp.dao.impl.StudentsDAOImpl@1ba92db
Hibernate:select top 2 students0_.id as id0_,students0_.class_id as class2_0_,students0_.name as name0_,students0_.age as age0_ from students students0_ order by students0_.id desc
Hibernate:select count(*) as col_0_0_ from students students0_
2011-8-15 16:27:36 org.apache.catalina.core.ApplicationDispatcher invoke
严重:Servlet.service() for servlet jsp threw exception
org.hibernate.LazyInitializationException:could not initialize proxy - the owning Session was closed
\x05at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:56)
\x05at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:98)
\x05at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:158)
\x05at com.accp.entity.Classes$$EnhancerByCGLIB$$d773eff9.getName()
\x05at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
\x05at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
\x05at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
\x05at java.lang.reflect.Method.invoke(Method.java:597)
.
▼优质解答
答案和解析
就是在Hibernate 映射表的xml 文件中.将many -to -one 里面加一个lazy="false"