공부
[Error 해결법] SpringBoot/JPA - Executing an update/delete query; nested exception is javax.persistence.Transaction 에러 해결
BeforB
2020. 4. 8. 21:34
728x90
에러 발생
- Spring Boot에서 JPA를 사용하던 중 DB에서 row를 삭제처리하기 위해 Repository에 update 쿼리문을 넣어주었더니 Service에서 update 처리를 할 때 Transaction 에러가 발생했다.
에러문
- org.springframework.dao.InvalidDataAccessApiUsageException: Executing an update/delete query; nested exception is javax.persistence.Transaction
... at org.springframework.orm.jpa.EntitManagerFactoryUtils.convertJpaAccessExceptionIfPossible ....
원인
- Spring Boot에서 JPA를 사용할 때 update나 delete문을 쿼리로 직접 사용할 경우에는 Transaction 처리를 직접 해주어야 한다.
해결법
- Repository의 delete메서드를 직접 불러오는 ServiceImpl의 delete함수 위에 @Transactional annotation을 추가해준다.
728x90