在Get方法中,不能写Save

    是一个比较弱智的问题。昨天写一个工时调整的方法。结果员工提出在保存时会报错。错误大概如下:
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.

    我一开始以为是代码写错了,拿回来查了半天。发现没招了。怎么查都没有错误。后面叫另一位员工 一起查。没多久,说OK了。我那个汗啊。原来是,在Get方法中写Save!太无语了。。。。。。浪费我老多时间。以后发现这个问题,要先找到源头的那个方法看一下方法名。
    <aop:config>
        <aop:advisor id="managerTx" advice-ref="managerTxAdvice" pointcut="execution(* *..service.*Manager.*(..))" order="0"/>
    </aop:config>
    
    <tx:advice id="managerTxAdvice">
        <tx:attributes>
            <tx:method name="get*" read-only="true"/>
            <tx:method name="*"/>
        </tx:attributes>
    </tx:advice>

你可能感兴趣的:(xml)