본문 바로가기
Error

No EntityManager with actual transaction available for current thread - cannot reliably process 'persist' call 에러

by YoonJong 2022. 6. 16.
728x90

JPA 테스트 코드 작성 및 실행 중 

No EntityManager with actual transaction available for current thread - cannot reliably process 'persist' call

해당 에러가 발생했다.

 

대충 뜻은 persist call 을 진행할 수 없다는 뜻인데, 옆에 에러코드를 보면 

현재 스레드에 실제 트랜잭션을 사용할 수 있는 EntityManager가 없음 - '지속' 호출을 안정적으로 처리할 수 없음 

이런 뜻이다.

 

JPA는 기본적으로 트랜잭션을 기반으로 작동하게 되어있다.

 

트랜잭션에 따라서 1차캐시영역에 있는 데이터들이 flush되어 영속화가 되기 때문이다

 

따라서 클래스나 서비스 메서드에 꼭 @Transactional 을 추가해주자!

728x90

댓글