org.hibernate.LazyInitializationException: could not initialize proxy - no Session org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:132) org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:174) org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190) com.sise.domain.User_$$_javassist_14.getType(User_$$_javassist_14.java) com.sise.action.QuestionAction.execute(QuestionAction.java:29) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:597)
查看实体类文件,发现访问的列为
@ManyToOne(fetch = FetchType.LAZY
把FetchType改为EAGER就没问题了
@ManyToOne(fetch = FetchType.EAGER