Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)
来源:互联网 发布:淘宝二次元 编辑:程序博客网 时间:2024/04/29 12:56
在使用Spring+Hibernate或Spring+Hibernate+Struts进行增删改时会提示:
Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)
分析原因如下:
在使用Spring+Hibernate或Spring+Hibernate+Struts的时候,会开启OpenSessionInViewFilter来阻止延迟加载的错误,但是在我们开启OpenSessionInViewFilter这个过滤器的时候,FlushMode就已经被默认设置为了MANUAL,如果FlushMode是MANUAL或NEVEL,在操作过程中 Hibernate会将事务设置为readonly,所以在增、删、修操作过程中会提示以上错误信息。
解决办法有两个:
(1)在web.xml配置文件中的那个OpenSessionInViewFilter里面加上如下初始参数:
<init-param> <param-name>flushMode</param-name> <param-value>AUTO</param-value> </init-param>
(2)在执行增、删、修之前加上如下代码:
this.getHibernateTemplate().getSessionFactory().getCurrentSession().setFlushMode(FlushMode.AUTO);
交流探讨到我的新浪微博:http://weibo.com/tianrui1990
欢迎关注技术分享微信公众号:JavaQ
- 错误:Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)
- Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into
- 错误:Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)..
- Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into
- Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)..
- Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)
- Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into
- 错误:Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)..
- Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)异常解决方法
- Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)
- Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into
- Spring+Hibernate报错:Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)
- 关于Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)
- Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into
- Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL):
- Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into
- 解决 Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session in
- Write operations are not allowed in read-only mode 只读模式下(FlushMode.NEVER/MANUAL)写操作不允
- Unity3d 协同 Photoshop 工作流
- OpenCV的HoG特征点详解
- max sum(DP)
- RESTful客户端库:RestClient
- OpenCV的HOG与SVM
- Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)
- 三色球问题
- Super Jumping! Jumping! Jumping!(DP)
- 无限式查找
- OpenCV图像中寻找最大区域Max_Area
- Binary Tree Zigzag Level Order Traversal
- 命运(DP)
- 位运算实现加法--2013-06-01
- JavaFX 各种内建built-in布局管理器的使用