spring jpa update更新数据不生效

遇到springjpa 有时候更新数据成功,有时候又失败了,还是要开启清空缓存和将更新强制刷入数据库

@Modifying(
clearAutomatically = true, // 清空EntityManager缓存,避免读旧数据
flushAutomatically = true // 强制将更新刷入数据库(关键!解决“执行了但没刷库”)
)
@Transactional
@Query(nativeQuery = true, value =
"UPDATE crowd_special_detail SET placement_where_cond = :placementWhereCond, placement_udaf_cond = :placementUdafCond " +
"WHERE crowd_id = :crowdId AND id_type = :idType"
)
Integer updatePlacementWhereCondAndUdafCond(
@Param("crowdId") Integer crowdId,
@Param("idType") String idType,
@Param("placementWhereCond") String placementWhereCond,
@Param("placementUdafCond") String placementUdafCond
);
posted @ 2026-03-12 10:56  my日常work  阅读(5)  评论(0)    收藏  举报