Write operations are not allowed in read-only mode (FlushMode.MANUAL)错误的解决方法

来源:互联网 发布:用友仓库软件 编辑:程序博客网 时间:2024/05/20 06:08

异常:Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.

直到DaoIpml.java 都是正确的,
DaoIpml.java中的源码
@Override
public void addSourceIndustry(SourceIndustry sourceIndustry) {
this.getHibernateTemplate().saveOrUpdate(sourceIndustry);
}

在使用save()方法 保存数据时,一直无法保存。

火狐浏览器报错:

Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.



解决方法:
   将createAdmin方法配置到spring的事件中管理,添加了以下的一条配置

  <tx:method name="create*" propagation="REQUIRED"/>



具体spring事件配置如下:

  <aop:config>
<aop:pointcut id="txServices"
expression="execution(* com.trig.service..*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="txServices" />
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="create*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>



0 0
原创粉丝点击