티스토리 뷰

org.springframework.dao.InvalidDataAccessApiUsageException

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: No EntityManager with actual transaction available for current thread - cannot reliably process 'remove' call; nested exception is javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process 'remove' call

org.springframework.dao.InvalidDataAccessApiUsageException: No EntityManager with actual transaction available for current thread - cannot reliably process 'remove' call; nested exception is javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process 'remove' call

javax.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process 'remove' call



Spring JPA @Repository에서 deleteByName을 사용하려고 하는데 오류가 발생하였다. Spring-data-jpa 1.7.x 이상 부터 deleteBy 또는 removeBy를 이용한 delete 쿼리를 사용할 수 있고 기존에 잘 사용하고 있었다.


해결방법은 메소드 위에 @Transactional 명시해 주면 끝...


기존에는 @Service 메소드에서 @Transactional 어노테이션을 명시해 놓은 클래스를 상속받아 사용하였기 때문에 오류가 발생되지 않았던 것이다.




Spring Data: “delete by” is supported?


Spring Data JPA - Reference Documentation -> 3.1. Core concepts


댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함