TroubleShooting

org.springframework.dao.TransientDataAccessResourceException: Cannot change the ExecutorType when there is an existing transaction 해결방법!

에디개발자 2020. 11. 4. 07:22
반응형

Batch 프로젝트를 진행중에 아래와 같은 에러 발생하였습니다. Batch 삽질 삽질 삽질

에러 원인을 요약하자면 하나의 트랜잭션 안에서 다른 실행자를 사용할 수 없다라는 내용이다. 자세한 내용을 찾아보니 실행자 타입 문제였다. MybatisPagingItemReader는 실행자 BATCH를 사용하고 있었다. 참조

org.springframework.dao.TransientDataAccessResourceException: Cannot change the ExecutorType when there is an existing transaction

 

 

내가 만든 프로젝트는 Reader에서 MybatisPagingItemReader를 이용해 데이터를 조회하고 Processor에서도 Mapper를 통해 데이터를 조회하는 프로젝트였다.

 

Reader에서 MyBatisPagingItemReader를 사용하여 데이터를 조회한다.

 

Processor에서 Mapper를 이용해 데이터를 조회하고 있다.

 

Reader에서는 MybatisPagingItemReader(excutor type : BATCH)를 쓰고 Processor에서는 Mapper(excutor type : SIMPLE)을 쓰려고 하니 에러 발생하는 것이었다. JPA와 QueryDSL을 도입해야하는 이유가 하나 더 늘었다. 이러한 이유로 SIMPLE 타입인 MybatisCursorItemReader를 사용하여 Processor, Writer 작성하여 배치 테스트 완료하였습니다.

 

대용량 데이터를 처리해야하는 데 MybatisCursorItemReader는 아니다!

 

빠른 시일 내에 JPA와 QueryDSL을 도입하여 수정할 것이다!

반응형