08-07
23
could not initialize proxy - no Session
作者:Java伴侣 日期:2008-07-23
还是关于could not initialize proxy - no Session的问题
hibernate2与hibanete3在lazy的默认值上有区别:2中默认为lazy="false".而三中默认为proxy,我们可以把它看作是true.
异常:
程序代码
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)
原因:hibernate3 many-to-one的默认选项是 lazy = "proxy"
解决方法:<many-to-one> & <set> 中设置 lazy="false"
如果还不行,根据自己需求,经过我的仔细排查放在set一端不行,那就放在<many-to-one>那端
hibernate2与hibanete3在lazy的默认值上有区别:2中默认为lazy="false".而三中默认为proxy,我们可以把它看作是true.
异常:
程序代码
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)
原因:hibernate3 many-to-one的默认选项是 lazy = "proxy"
解决方法:<many-to-one> & <set> 中设置 lazy="false"
如果还不行,根据自己需求,经过我的仔细排查放在set一端不行,那就放在<many-to-one>那端
评论: 0 | 引用: 0 | 查看次数: 2907
发表评论