org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role:XXX
2014-06-27 18:43
639 查看
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.zznode.inms.pdm.data.ProjectBatchUpdateTask.devicePrjChangeTasks, no session or session was closed at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358) at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350) at org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:97) at org.hibernate.collection.PersistentSet.size(PersistentSet.java:114)
原因:在hibernate的映射关系中由于延迟加载,之前的操作使session已经关闭,所以加载set属性时无可用session
解决办法:在映射文件中设置set属性 lazy='false'
<set name="devicePrjChangeTasks" lazy="false" cascade="delete" inverse="true"> <!-- 主键对应的关联表外键 --> <key column="prj_update_task_id"></key> <!-- 关联表 --> <one-to-many class="com.zznode.inms.pdm.data.ProjectUpdateTemp"/> </set>
相关文章推荐
- org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.eng
- org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.jav
- org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role
- org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: XXXX
- org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role:no sessi
- org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role
- SSH报错之 hibernate.LazyInitializationException: failed to lazily initialize a collection of role: XXXX
- Hibernate:LazyInitializationException: failed to lazily initialize a collection of rol
- ejb 学习:遇到错误:LazyInitializationException.<init> : failed to lazily initialize a collection of role:
- org.hibernate.LazyInitializationException: failed to lazily initialize a collection..的解决方案
- ERROR LazyInitializationException:19 - failed to lazily initialize a collection of role: com.goodfan.entity.BeanA.beanB, no session or session was closed
- org.hibernate.LazyInitializationException: failed to lazily initialize
- 解决:org.hibernate.LazyInitializationException: failed to lazily initialize(2013-04-28 14:49:47)
- could not initialize proxy - no Sessionorg.hibernate.LazyInitializationException: failed to lazily
- org.hibernate.LazyInitializationException: failed to lazily initialize
- [BlazeDS]Exception occurred during serialization: org.hibernate.LazyInitializationException: failed to lazily initialize a colle
- [BlazeDS]Exception occurred during serialization: org.hibernate.LazyInitializationException: failed to lazily initialize a colle
- 问题:org.hibernate.LazyInitializationException: failed to lazily initialize
- org.hibernate.LazyInitializationException: failed to lazily initialize
- org.hibernate.LazyInitializationException: failed to lazily initialize a col