在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.
<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>