spring-hibernate修改数据报错

来源:互联网 发布:涂鸦移动 知乎 编辑:程序博客网 时间:2024/06/10 03:40

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

执行的方法不再设置范围内,hibernate默认为readonly:解决方案,将方法对应的包移动至com.document包下

<aop:config>
<aop:pointcut id="bussinessService"
expression="execution(public * com.document..*.*(..))" />
<aop:advisor pointcut-ref="bussinessService"
advice-ref="txAdvice" />
</aop:config>


<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<!-- <tx:method name="getUser" read-only="true" /> -->
<!-- <tx:method name="add*" propagation="REQUIRED"/> -->
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>



0 0
原创粉丝点击