异常记录

spring 环境下做一个保存操作时,抛出如下异常:

     org.springframework.dao.InvalidDataAccessApiUsageException: 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.

<!-- 配置事务特性 -->      
<tx:advice id="txAdviceBHO" transaction-manager="transactionManager">
    <tx:attributes>
       <tx:method name="save*" propagation="REQUIRED" />
       <tx:method name="update*" propagation="REQUIRED" />
       <tx:method name="delete*" propagation="REQUIRED" />
       <tx:method name="*" read-only="true" propagation="NEVER"/>
    </tx:attributes>
</tx:advice>


原因 在于配置事务时有错误,我调用的方法为orderSave,操作为保存数据,而在如下配置中针对此方法只能做读取操作,就出现了如上异常




你可能感兴趣的:(spring,transaction)