当前位置: 代码迷 >> 综合 >> Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into Flush
  详细解决方案

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

热度:19   发布时间:2023-12-25 23:28:29.0

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.

该异常信息表示在执行方法对数据库进行操作时,该方法时只读模式,无法进行更新,添加,删除操作,在网上找了很多方法,有说在方法上添加@Transaction(readOnly = false),但是我尝试了该方法,最终无效,最终经本人测试,该方法是有效的,在对数据库操作的方法中添加以下代码:

hibernateTemplate.setCheckWriteOperations(false);

希望这篇文章能够帮助到各位大佬们!!!

  相关解决方案