Spring Boot/Exception handling

[JPA] deleteBy 오류 및 ResultSet 오류

y0ngha 2021. 11. 18. 17:47

프로젝트에서 생성할 거 다 생성하고, 이제 DELETE를 해줘야하는 것이 남았는데 DELETE를 진행했더니 아래와 같은 오류가 나왔다.

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

이게 무슨 오류인가... 구글링을 해봤더니, deleteBy를 쓰는 repository에 @Transactional 어노테이션이 없어서 나오는 오류라고 한다.

repostitory에 @Transactional을 달았더니 오류는 사라졌다.

 

그러고 나니 아래와 같은 오류가 나왔다.

org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet

이 오류는 또 뭔가.. 하고 찾아봤더니, Entity에서 사용하기로 한 Table이 없을 때 나오는 오류라고 한다.

근데 찾아보니 Table은 있다.

근데도 오류가 나고 있는 이유를 찾았더니, Entity에 Table에는 없는 필드를 선언해놔서 그렇다.

없애니까 잘 작동한다.

 

Spring boot는 오류메시지가 참 해석하기 힘들다.