Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushM
来源:互联网 发布:视频添加背景音乐软件 编辑:程序博客网 时间:2024/05/22 13:08
当我写数据的时候出现上面异常,查啊查,应该是保存数据时采用了默认的只读模式。
网上的方法配置事务:
1:
<!-- 定义事务管理 --> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- 配置事务异常封装 --> <bean id="persistenceExceptionTranslationPostProcessor" class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" /> <!-- 声明式容器事务管理 ,transaction-manager指定事务管理器为transactionManager --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="get*" propagation="REQUIRED" /> <tx:method name="*" read-only="true" /> </tx:attributes> </tx:advice> <aop:config expose-proxy="true"> <!-- 只对业务逻辑层实施事务 --> <aop:pointcut id="txPointcut" expression="execution(* com.zq.app.cms.service..*.*(..))" /> <!-- Advisor定义,切入点和通知分别为txPointcut、txAdvice --> <aop:advisor pointcut-ref="txPointcut" advice-ref="txAdvice"/> </aop:config>
2.修改默认只读模式:
<filter> <filter-name>OpenSessionInViewFilter</filter-name> <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class> <init-param> --> <param-name>sessionFactoryBeanName</param-name> <param-value>sessionFactory</param-value> </init-param> <init-param> <param-name>flushMode</param-name> <param-value>AUTO</param-value> </init-param> </filter> <filter-mapping> <filter-name>OpenSessionInViewFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
都没用。费解。。。
我采用的是spring 4.20 hibernate 4.3.10.Final
把 penSession()方法中 session.setFlushMode(FlushMode.MANUAL); 改为session.setFlushMode(FlushMode.AUTO);
结果是可以的。
阅读全文
0 0
- Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushM
- Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushM
- Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushM
- Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushM
- Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushM
- Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushM
- 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 into
- 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 into
- 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 into
- 解决:Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into Flu
- Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly
- Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly
- Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly
- Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly
- Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or r
- 关于同步另一个系统的数据
- Html的学习笔记
- Spring --AOP
- SD卡于TF卡的区别
- 我所理解的linux kernel的移植
- Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushM
- Android--手势
- 2017.07.10回顾
- 多道程序系统
- sql-
- 在程序中获取当前用户信息的方法
- Git的使用
- 关于OOM的那些事儿
- AVL(高度平衡的二叉树)