今天上午做了一个ssh的组织机构增删改查的例子。crud还有分页都没有问题。可是今天下午我再打开试试的时候不行了,
分页没有问题,可是增删改都不行了。
老是报以下错误:Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' er from transaction definition.
我上网查了一下,有的说是spring配置错了,可是刚才加入初始数据的时候是没有错的,加上了。后来没有改。
以下是spring的固定配置(觉的不是这里的问题):
<!-- 配置事务特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="find*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 配置那些类的方法进行事务管理 -->
<aop:config>
<aop:pointcut id="allManagerMethod" expression="execution (* com.djrj.oa.manager.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/>
</aop:config>
分页没有问题,可是增删改都不行了。
老是报以下错误:Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' er from transaction definition.
我上网查了一下,有的说是spring配置错了,可是刚才加入初始数据的时候是没有错的,加上了。后来没有改。
以下是spring的固定配置(觉的不是这里的问题):
<!-- 配置事务特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="find*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 配置那些类的方法进行事务管理 -->
<aop:config>
<aop:pointcut id="allManagerMethod" expression="execution (* com.djrj.oa.manager.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/>
</aop:config>
解决方案 »
- 数据库中的简单问题
- 推荐一本Java基础书籍 要讲的有深度的那种
- java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] 语法错误 (操作符丢失)问题
- 网页地址栏的小图标,有没办法全局设置呢?
- struts1的.do页面无法加载外部的js文件
- myeclipse导入struts和hibernate项目问题
- 问个UltraEdit中正则表达式的问题?
- Spring配置文件的加载问题(非applicationContext)
- 极菜问:如何锁住文件不让别的程序或人修改删除,高分求教
- maven中添加了springboot后报错
- 如何获取运行telnet命令后返回的xml字串信息
- XML读取
<tx:method name="*" read-only="true"/>
改成
<tx:method name="find*" propagation="REQUIRED">
<tx:method name="*" read-only="true"/>
</tx:method>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:method name="find*" propagation="REQUIRED" read-only="true" />
<tx:method name="*" propagation="REQUIRED" />
</tx:advice>
用这个试下