项目中有时候会遇到插入数据到表中去报错只读模式

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.

这种错误如果之前一直没有,且未曾修改app-config-context.xml配置文件,突然就出现了此类问题,一般都是由于自己开发中方法名取名和配置文件中配置项冲突

关于hibernate中插入数据报read-only mode只读模式错误

例如方法名取名为  public void getsomething(){},若此方法中有事务提交(增、删、改)表操作,将会报上述错误,因为配置项中已经配置get*为只读模式,故只需将自己方法名中的get去掉或替换即可。

再重启服务测试,此时发现问题得以解决!!

 

 

相关文章:

  • 2022-12-23
  • 2021-08-24
  • 2021-04-29
  • 2022-12-23
  • 2021-04-20
  • 2021-11-23
  • 2021-09-13
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-15
  • 2022-12-23
  • 2021-10-27
  • 2021-07-04
  • 2021-11-03
  • 2021-05-13
相关资源
相似解决方案