关于Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)
来源:互联网 发布:调色软件vsco下载 编辑:程序博客网 时间:2024/04/29 08:13
我在使用hibernateTemplate的时候遇到这个问题,此问题是由于session被设置成了FlushMode.NEVER/MANUAL模式,是不支持写操作的。我在网上搜了很长时间,大概就是两种方法,没有解决我的问题,如下:
第一种:
web.xml配置里添加
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
<init-param>
<param-name>sessionFactoryBeanName</param-name>
<param-value>sessionFactory</param-value>
</init-param>
<init-param>
<param-name>singleSession</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name> flushMode </param-name>
<param-value>AUTO </param-value>
</init-param>
</filter>
第二种是:
如果在交给spring 管理的情况下,在beans.xml 里的配置
<bean id="txManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<aop:config>
<aop:pointcut id="bussinessService"
expression="execution(* com.fan.service.base.*.*(..))" />
<aop:advisor pointcut-ref="bussinessService"
advice-ref="txAdvice" />
</aop:config>
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="get*" read-only="false" propagation="NOT_SUPPORTED"/>
<tx:method name="find*" read-only="false" propagation="NOT_SUPPORTED"/>
<tx:method name="save*" propagation="REQUIRED"/> // 如果不把save update delete都配置上,
<tx:method name="update*" propagation="REQUIRED"/> //这些操作会无效
<tx:method name="delete*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
我最后在Stack Overflow找到了第三种方法,解决了我的问题:
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"></property>
<property name="checkWriteOperations" value="false"></property>
</bean>
在这里多添加一行<property name="checkWriteOperations" value="false"></property>即可
- 关于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)..
- 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): 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
- 关于ssh里面的Write operations are not allowed in read-only mode (FlushMode.NEVER)
- 解决 Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session in
- hadoop命令总结
- 树,森林与二叉树的转换
- Openstack虚拟机在线迁移(Live Migration)
- 欢迎使用CSDN-markdown编辑器
- yii2基础(五)
- 关于Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)
- 开篇
- 设计模式笔记:代理模式
- DOM 事件模型
- Delphi 变体类型(Variant)的介绍(流与变体类型的相互转换、变体类型常用的函数)
- IIS和.net FrameWork安装顺序
- bzoj2653: middle
- C++: 详解 使用Schrage's Method Revealed 实现随机化算法
- git 命令行