hibernate的load方式加载lazy属性的pojo出错

2013-07-18 15:28:14-Checking ConfigurationProviders for reload.
2013-07-18 15:28:14-could not initialize proxy - no Session
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
	at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:132)
	at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:174)
	at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)
	at cn.itcast.bean.Person_$$_javassist_0.getName(Person_$$_javassist_0.java)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
环境 hibernate3.0 + spring3.0:
-- 加载一个简单对象(无集合属性),取某字段内容取不到。
-- 以load方式加载就出错(配置了openSessionInView,也一样出错),get方式没问题

解决:
-- pojo默认lazy方式,默认是true。指定lazy=false。问题解决

ref: http://hi.baidu.com/362217990/item/5fe7b784213207c8ef083d7d
-- 参考中,说以openSessionInView方式能解决,但实验后不行

开发网站 http://www.finebornchina.cn 进行性能优化时碰到上述问题

你可能感兴趣的:(Hibernate)