TroubleShooting 3

TransientDataAccessResourceException

문제 Spring batch 사용 시 Read 방식을 List로 구현하였을 때에는 정상적으로 동작이 수행되었다이후, read방식을 paging 으로 변경 후 quartz가 실행되었을 때, TransientDataAccessResourceException 발생하였다. org.springframework.dao.TransientDataAccessResourceException: Cannot change the ExecutorType when there is an existing transaction 문제의 본질mybatis는 내부적으로 3가지 실행자(executor)를 지원한다.SIMPLE (디폴트) : 구문 실행마다 새로운 PreparedStatement를 생성REUSE : PreparedStateme..

TroubleShooting 2025.06.02

JPA delete 후 insert가 안될 때(duplicate entry error)

문제 우선 user와 userImage가 OneToOne 관계를 가지고 있었다. user의 이미지 수정 요청 시, delete 후 insert 하기 위해 코드를 구현하는 와중에 duplicate entry error가 발생했다. unique 조건이 있는 데이터인데 삭제가 되지 않은 채로 추가를 하려 해서 발생하는 에러였다. 로그를 확인해도 delete코드가 먼저 적혀있음에도 불구하고 insert를 먼저 실행하는 것을 확인할 수 있다. 찾아보니 hibernate에서 동작하는 SQL 순서가 정해져 있었다. 시도 entityManager의 flush 메서드를 사용하여 손쉽게 영속성 컨텍스트의 변경내용(delete)을 DB에 동기화할 수 있었다. 하지만 하나의 요청을 위해 entityManager를 호출하는 것..

TroubleShooting 2023.09.03

[TroubleShooting] InvalidDefinitionException

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `org.springframework.data.domain.PageImpl` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator) 따로 캡처는 못했지만 Redis로 Page를 Caching 할 때 발생한 에러다. `org.springframework.data.domain.PageImpl` 클래스에 기본 생성자가 없어서 발생한다고 했다. 어떻게 해야할 지 고민하다가 PageI..

TroubleShooting 2023.08.06