Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushM

来源:互联网 发布:sql 删除数据语句 编辑:程序博客网 时间:2024/05/22 15:47

错误提示: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.


我在删除一条数据时出现了以上错误,网上查询的答案基本是说这个错误一般由事务引起的,有可能是项目事务配置文件不正确,但是我删除其它数据并没有出现这个问题,所以不存在项目事务配置文件不正确的问题。


经过逐字逐行的对比代码,发现原来是我在删除方法上忘记了添加Spring注解@Transactional来配置事务。



PS:项目事务配置文件存在问题可查看博客1和博客2

1 0
原创粉丝点击