org.hibernate.LazyInitializationException: could not initialize proxy - no Session

Exception in thread "main" org.hibernate.LazyInitializationException: could not initialize proxy - no Session
    at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
    at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
    at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150)
    at cn.itcast.hibernate.domain.User$$EnhancerByCGLIB$$ce067ed6.getName(<generated>)
    at cn.itcast.hibernate.Base.main(Base.java:41)

 

这个问题是使用hibernateload出现的。原因是使用了懒加载,只有在使用的时候才执行数据库对应操作,但是在那个时候我们的session已经关闭了

posted @ 2016-08-22 13:59  guodaxia  阅读(96)  评论(0编辑  收藏  举报