BACK/JPA
[JPA] Executing an update/delete query 에러 해결
연듀
2022. 8. 31. 17:44
Executing an update/delete query; nested exception is javax.persistence.
TransactionRequiredException: Executing an update/delete query with root cause
에러문 그대로 JPA에서 update/delete 쿼리를 사용할 때는 Transaction 처리를 해줘야 한다.
@Transactional
@Modifying(clearAutomatically = true)
@Query("UPDATE Share s SET s.progress= :progress WHERE s.user.userId= :userId and s.post.id = :postId")
void updateProgress(Long userId, Long postId, int progress);
이렇게 @Transactional 어노테이션을 추가하니 해결됐다.
반응형