Write operations are not allowed in read-only mode (FlushMode.NEVER/

今天在做ssh项目开发的时候遇到一个问题,保存数据的时候报错:

Write operations are not allowed in read-only mode (FlushMode.NEVER/

后参考这篇文章才知道出了什么问题:http://www.aichengxu.com/view/37412

原来在Spring事务管理中save类的方法都没有read-only=true,但是我的方法是add*,所以就出现开头讲的问题,把add*方法改成save*就可以了。

<!-- 配置事务策略 -->
    <tx:advice id="txAdvice" transaction-manager="myTxManager">
        <tx:attributes>
            <tx:method name="find*" propagation="REQUIRED" read-only="true" />
            <tx:method name="save*" propagation="REQUIRED" />
            <tx:method name="*" propagation="SUPPORTS" read-only="true" />
        </tx:attributes>
    </tx:advice>

 

posted @ 2015-01-16 17:02  Seaurl  阅读(231)  评论(0编辑  收藏  举报