记一次工作中使用spring jpa遇见的坑。

发布时间 2023-12-19 08:56:40作者: 阿灿呀

报错: RROR oro.hiberate.enoineidcsvi salexceptionhelner Connection is read-only,Cueries leading to data modification are not allowed
org.springframework.orm.jpa.JpaSystemException: could not execute statement; nested exception is
org.hibernate.exception.GenericJDBCException: could not execute statement
场景:我们项目配置了事务管理器,当方法有update、add、save。。。等等时会自动加事务,此次坑就是因为这个。。。
我命名了一个query方法名(不会自动加事务),然后想在里面测试增删改查方法再继续往下做,结果除了查询方法,其他方法都报错或不生效。。。
排查一圈才发现是少了事务