org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role
来源:互联网 发布:同步推mac 编辑:程序博客网 时间:2024/06/05 05:10
ERROR LazyInitializationException:42 - failed to lazily initialize a collection of role: com.cdf.oa.bean.Role.privileges, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.cdf.oa.bean.Role.privileges, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:383)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:375)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:368)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:111)
at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:186)
at cn.itcast.oa.bean.User.hasPrivilegeByName(User.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
如上红色部分所示:一个集合的的列懒加载失败:对应bean文件Role的privileges属性,所以运行到User.java:37行出错
解决办法:在hibernate的映射关系中由于延迟加载,之前的操作使session已经关闭,所以加载set属性时无可用session
在Role的映射文件中设置set属性 lazy='false'
- 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: com.eng
- org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role:XXX
- org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role
- org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role
- org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.jav
- org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: cn.oa.d
- SSH报错之 hibernate.LazyInitializationException: failed to lazily initialize a collection of role: XXXX
- Hibernate:LazyInitializationException: failed to lazily initialize a collection of rol
- Hibernate问题 failed to lazily initialize a collection of role
- ejb 学习:遇到错误:LazyInitializationException.<init> : failed to lazily initialize a collection of role:
- org.hibernate.LazyInitializationException: failed to lazily initialize a collection..的解决方案
- org.hibernate.LazyInitializationException: failed to lazily initialize a col
- org.hibernate.LazyInitializationException: failed to lazily initialize
- org.hibernate.LazyInitializationException: failed to lazily initialize
- failed to lazily initialize a collection of role:
- failed to lazily initialize a collection of role:
- java_笔记-9
- JavaScript HTML DOM 事件
- 威佐夫博弈(介绍)
- Node.js实践HTTP安全认证之一~~基本认证
- Python_List对象内置方法详解
- org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role
- LeetCode----Word Pattern
- 大整数取模
- 会议2_2015阿帕奇路演(中国站)大数据生态链分场内容概览
- JS学习实例:JavaScript时钟及Date对象学习总结
- 永久性保存
- jdk1.6.0_45的安装配置及环境变量的配置
- Xamarin.Android支付宝SDK Demo
- 常规选择器