Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- list 컬렉션
- R
- Algorithm
- 이스케이프 문자
- Selection Sorting
- Serialization
- s
- Graph
- 윤성우의 열혈 자료구조
- stream
- 혼자 공부하는 C언어
- 메모리구조
- insertion sort
- C programming
- datastructure
- Stack
- 윤성우 열혈자료구조
- 이것이 자바다
- JSON
- 알기쉬운 알고리즘
- C 언어 코딩 도장
- buffer
- coding test
Archives
- Today
- Total
Engineering Note
[Error Handling] flush 메서드 오류 본문
에러메세지
jakarta.persistence.TransactionRequiredException: No EntityManager with actual transaction available for current thread - cannot reliably process 'flush' call
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:304)
at jdk.proxy2/jdk.proxy2.$Proxy157.flush(Unknown Source)
at com.shop.repository.ItemRepositoryTest.findByItemDetailTest(ItemRepositoryTest.java:226)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
에러메세지를 확인하면 transaction이 없는 상태에서 flush를 호출했다는 에러메세지다. 발생한 위치는 ItemRepositoryTest의 226번라인이다.
알아두어야 할 개념
- flush()는 Persistence Context의 변경사항을 DB에 반영하는 작업
- JPA에서 Persistence Context(영속성 컨텍스트)는 트랜잭션과 생명주기를 같이하는 데 당연히 트랜잭션의 시작을 알려주는 @Transaction 어노테이션이 없으면 영속성 컨텍스트도 없고 flush 메서드를 호출 할 수 없다.
'Error Handling' 카테고리의 다른 글
[Error Handling] Thymeleaf Parsing Error, NotReadablePropertyException 예외 (0) | 2025.09.16 |
---|---|
[Error Handling] 파일 업로드 테스트 에러 해결 (0) | 2025.09.15 |
[Error Handling] Spring Security 로그아웃 버그 해결 (0) | 2025.09.14 |
[Error Handling] DB 연결 설정 테스트 문제해결, ActiveProfile로 테스트 환경 관리 (0) | 2025.09.13 |
[Error Handling] Spring Security 로그인 테스트에서 userParameter 설정 이슈 해결 (0) | 2025.09.12 |
Comments