spring boot jpa 同一事务内数据不一致问题
最近在spring boot内使用hibernate jpa时遇到一个问题,容器使用的是内置tomcat,使用 @transactional 注解写到了 service方法上。
使用tomcat容器启动时调用repository的update方法再在同一方法内部读取后并不是update后的数据,而是之前的数据。
但是使用单元测试时同样的代码读取正常。
将@transactional注解放到repository的update方法上也是和上边同样的现象
有没有大神遇到过类似现象,是哪里配置出了问题吗
spring.datasource.url=
spring.datasource.username=
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.tomcat.max-active=200
spring.datasource.tomcat.max-idle=200
spring.datasource.tomcat.initialSize=20
spring.datasource.tomcat.default-auto-commit=true