No EntityManager with actual transactionavailable for current thread

原因:更新或删除没有加事务
解决办法:
1、在Service层加@Transactional
2、在Repository层加@Modifying

jpa delete id列表

这里写图片描述
jpa竟然根据id删除,这样效率极低,原因查看jpa源码
解决办法:

    @Modifying
    @Query("delete from DeviceGpsLog where createTime < ?1")
    public void deleteByCreateTimeBefore(Date createTime);
Logo

欢迎加入DeepSeek 技术社区。在这里,你可以找到志同道合的朋友,共同探索AI技术的奥秘。

更多推荐