Write operations are not allowed in read-only mode
2015-04-28 14:43
405 查看
在使用hibernate时,我遇到了这样一个问题
Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.
后来研究发现,这是因为
使用了OpenSessionInViewFilter所致,只需要使用AOP将事务管理起来就可以解决该问题了
Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.
后来研究发现,这是因为
<filter> <filter-name>hibernateFilter</filter-name> <filter-class> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter </filter-class> </filter>
使用了OpenSessionInViewFilter所致,只需要使用AOP将事务管理起来就可以解决该问题了
<tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="del*" propagation="REQUIRED" /> <tx:method name="modify*" propagation="REQUIRED" /> <tx:method name="change*" propagation="REQUIRED" /> <tx:method name="*" read-only="false" /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="mypointcut" expression="execution(* service.*.*.*(..))" /> <aop:advisor pointcut-ref="mypointcut" advice-ref="txAdvice" /> </aop:config>
相关文章推荐
- Write operations are not allowed in read-only mode 只读模式下(FlushMode.NEVER/MANUAL)写操作不允
- 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
- Write operations are not allowed in read-only mode 只读模式下(FlushMode.NEVER/MANUAL)写操作不允
- hibernate框架学习错误集锦-org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.MANUAL)
- 解决Hibernate Write operations are not allowed in read-only mode的方法
- 解决: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
- Write operations are not allowed in read-only mode 只读模式下(FlushMode.NEVER/MANUAL)写操作不
- 使用Spring提供的Open Session In View而引起Write operations are not allowed in read-only mode (FlushMode.NEVER) 错误解决
- Write operations are not allowed in read-only mode (FlushMode.MANUAL)错误解决的一种方法
- Write operations are not allowed in read-only mode
- Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushM
- Write operations are not allowed in read-only mode
- Write operations are not allowed in read-only mode
- write operations are not allowed in read-only mode(flushMode.MANUAL)
- 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错误
- Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn
- hibernate异常:Write operations are not allowed in read-only mode