JPA javax.persistence.TransactionRequiredException

直接说一下解决方案

Dao层,一定要是Dao层。

1 增加Transactional,必须要事务!

2 增加Modifying,告诉jpa这是修改!

    @Transactional
    @Modifying
    @Query(value = "update A set s= :s where id=:id",nativeQuery = true)
    Integer updateReport(@Param(value = "s")String s,
                         @Param(value = "id")String id);

猜你喜欢

转载自www.cnblogs.com/hanjun0612/p/10402397.html
JPA
今日推荐