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
'공부' 카테고리의 다른 글
[배포] 1. Django EC2 배포 방법(feat. uWSGI) (0) | 2021.08.24 |
---|---|
[Network] Proxy란? Forward Proxy와 Reverse Proxy (0) | 2021.07.09 |
[Error 해결법] JPA - null value was assigned to a property [DTO] 해결법 (3) | 2020.04.08 |
[Error 해결법] Swagger base url Error - Swagger 링크로 이동되지 않고 에러날 때 (0) | 2020.04.08 |
[운영체제] 기술 면접 질문 대비 (0) | 2020.04.05 |
댓글