SSH整合报错:failed to lazily initialize a collection of role
来源:互联网 发布:祝利荣牛熊线指标源码 编辑:程序博客网 时间:2024/05/17 01:03
今天整合ssh,测试Dao层方法时,本地测试了一个方法 没有问题,
然而程序部署到tomcat上时却报了一个错误:
org.apache.struts2.json.JSONException: org.hibernate.LazyInitializationException:
failed to lazily initialize a collection of role: com.etoak.bean.Adarea.ads, no session or session was closed
大概意思是延迟初始化集合失败,没有会话或会话关闭。
网上两种办法:
第一种 : 把所有onetomany mangToone 映射的属性加上lazy=”false”,但据说这种办法会让
降低查询效率 。 所以不建议采用 小编就不赘述了
第二种 : 在web.xml中添加如下:
<filter> <filter-name>hibernateFilter</filter-name> <filter-class> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter </filter-class> </filter> <filter-mapping> <filter-name>hibernateFilter</filter-name> <url-pattern>*.action</url-pattern> </filter-mapping>
不过要注意 同时要在ioc容器中设置sessionFactory的实体bean id为sessionFactory ,不能随意定义了。
0 0
- SSH整合报错:failed to lazily initialize a collection of role
- failed to lazily initialize a collection of role:报错
- SSH报错之 hibernate.LazyInitializationException: failed to lazily initialize a collection of role: XXXX
- hibernate报错failed to lazily initialize a collection of role
- failed to lazily initialize a collection of role:
- failed to lazily initialize a collection of role:
- failed to lazily initialize a collection of role
- failed to lazily initialize a collection of role
- failed to lazily initialize a collection of role
- failed to lazily initialize a collection of role
- failed to lazily initialize a collection of role问题
- failed to lazily initialize a collection of role
- failed to lazily initialize a collection of role
- failed to lazily initialize a collection of role
- failed to lazily initialize a collection of role
- failed to lazily initialize a collection of role
- failed to lazily initialize a collection of role
- failed to lazily initialize a collection of role
- 2099 整除的尾数【暴力&&数学】
- JNI本地接口
- 不论做什么,都应该努力做到最好
- 如何快速梳理一个项目
- 一个二维码实现苹果和安卓两个市场安装包自动分发
- SSH整合报错:failed to lazily initialize a collection of role
- android-swipelistview使用说明
- Android中meta-data的使用
- HDU 4539 【状压DP】
- TestLink 与 Mantis的集成
- C编译预处理宏
- MYSQL的WHERE子句
- Redis命令
- iOS-浅谈runtime运行时机制01-类与对象的内部结构