Spring Data JPA 中使用Update Query更新实体类问题
更新:HHH   时间:2023-1-7


在jpa中使用@Modifying 虽然事务已经能够更新,但是在循环更新的时候,执行modify语句后的查询的实体仍然是没有更新的。

执行完modifying query, EntityManager可能会包含过时的数据,因为EntityManager不会自动清除实体。
只有添加clearAutomatically属性,EntityManager才会自动清除实体对象。

@Modifying(clearAutomatically = true)

返回软件技术教程...