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>
本文讨论了在使用Hibernate进行数据库操作时遇到的readonly模式限制问题,并提供了通过调整事务传播行为和移动方法包来解决该问题的方案。
3427

被折叠的 条评论
为什么被折叠?



