您的位置:首页 > 运维架构

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

2015-01-08 19:34 423 查看

异常: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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐