环境 spring+hibernate3+struts
failed to lazily initialize a collection of role: no session or session was closed
试验了一下发现了几个解决方法:
1、是把对应一对多的那两个列lazy=true改为lazy=false即可
2、对于查询中如果用的是xxx.load(class,id)则改为xxx,get(class,id)
3在web.xml文件中加入
<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
<init-param>
<param-name>singleSession</param-name>
<param-value>false</param-value>
</init-param>
<!--这个-- <init-param>一定要加不然很可能会报错:org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition
>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>*.mmg</url-pattern>
</filter-mapping>
分享到:
相关推荐
解决:com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after statement closed.
Download from your IP address is not allowed 百度网盘永久连接: QT下载: qt-opensource-linux-x64-5.8.0.run: 链接:https://pan.baidu.com/s/1sQ3tqPaWdDnmhBYAc_XR7g qt-opensource-linux-x64-5.13.1....
org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker ...
在使用Spring框架时,特别是在与Hibernate结合的情况下,可能会遇到“Write operations are not allowed in read-only mode (FlushMode.NEVER)”这样的异常。这个问题通常发生在使用Spring提供的Open Session In ...
设置隐试打开PPT报错 Hiding the application window is not allowed
xml/ns/javaee":deferred-syntax-allowed-as-literal, "http://java.sun.com/xml/ns/javaee":trim-directive-whitespaces, "http://java.sun.com/xml/ns/javaee":default-content-type, ...
解决fatal:remote error:You can’t push to git://github.com/username/*.git问题的办法 今天Git push的时候 fatal:remote error: You can't push to git://github....看来我是没有权限push啊。 解决方法: ...接
Android WebView 报 Not allowed to load local resource错误的解决办法 博客地址:http://blog.csdn.net/yuzhiqiang_1993/article/details/76228541
【九年级英语上册重点短语默写卷】 ...12. 不允许做某事:be not allowed to do sth. 这些短语涵盖了日常对话、写作及阅读理解等多个方面,通过反复练习和应用,学生可以更好地掌握这些重要短语,从而提升英语水平。
关键字:SQL0084 SQLCODE -84 说明: SQL statement not allowed. 说明:SQL 语句不允许的。 关键字:SQL0097 SQLCODE -97 说明: Use of data type not valid. 说明:使用的数据类型无效。 关键字:SQL0104 ...
Result:=Result+'export.allowed'#10'0'#10; Result:=Result+'import.allowed'#10'1'#10; Result:=Result+'import.silent'#10'1'#10; Result:=Result+'licensed.serialno'#10+SerialNumber+#10; Result:=Result...
NR5G 网络拒绝码 - 5gmm_cause = 7 (0x7) (5GS Service not allowed) 本资源摘要信息将详细解释 NR5G 网络拒绝码 5gmm_cause = 7 (0x7) (5GS Service not allowed),并对相关知识点进行详细说明。 一、NR5G 网络...
NULL 博文链接:https://rayoo.iteye.com/blog/1973032
java.sql.SQLException: null, message from server: “Host ‘223.72.41.7’ is not allowed to connect to this MySQL server” 客户端访问时报错: 解决方法: 1,登陆服务器 mysql> use mysql; //用mysql ...
9. 被允许做...:be allowed to do 10. 通过;完成:get through 11. 在...中发挥作用:play a role in 12. 应用:apply 13. 应该做:ought to do 14. 为...让路:give way to 15. 有用的:useful 16. 每四年:every...
message from server: “Host ‘****’ is not allowed to connect to this MySQL server 1:在登录mysql服务器 2:执行:GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ WITH GRANT OPTION //赋予任何主机访问数据的...
import cycle not allowed(解决方案).md
ERROR 1130 (HY000): Host ‘localhost’ is not allowed to connect to this MySQL server www.jb51.net 出现原因: mysql只有一个root用户,修改root密码后选了MD5,提交后,重新 登陆出现“Host ‘localhost’ is...
### Keil 编译器常见错误解析与解决方案 #### 一、Warning 280: ‘i’: unreferenced local variable **问题描述**:在编译过程中出现警告信息“Warning280: ’i’: unreferenced local variable”,表明在函数内部...