mybatis

개발/Spring

MyBatis cannot change the ExecutorType when there is an existing transaction 오류

스프링 배치 잡을 실행할 때 MyBatis 쿼리 실행 부분에서 다음과 같은 오류가 발생하는 경우가 있었다. cannot change the ExecutorType when there is an existing transaction이 에러는 존재하는 트랜잭션이 있을 경우 MyBatis의 ExecutorType (SIMPLE, BATCH, REUSE) 을 변경할 수 없다는 의미이다. 원인 스프링 배치 잡에서만 날 수 있는 오류는 아니고 MyBatis를 사용하고 트랜잭션 설정된 부분이 있다면 발생할 수 있을 것이다. 트랜잭션으로 묶여있는 범위 내에서는 배치 잡 내에서 동일 데이터 소스에 대해서는 동일 SqlSessionTemplate을 사용하게 될 것인데, ExecutorType은 SqlSessionTempl..

bebeside77
'mybatis' 태그의 글 목록