개발 기록

Cannot change the ExecutorType when there is an existing transaction 본문

TIL

Cannot change the ExecutorType when there is an existing transaction

수염차 2024. 2. 13. 14:00

https://tomining.tistory.com/178

 

Transaction 내에서 ExecutorType 변경 불가 오류

Spring-Batch로 개발을 진행하던 중 아래와 같은 오류를 접하였다. org.springframework.dao.TransientDataAccessResourceException: Cannot change the ExecutorType when there is an existing transaction 현상은 "Transaction내에서 ExecutorT

tomining.tistory.com

 

https://choisblog.tistory.com/81

 

Spring Batch Error : TransientDataAccessResourceException : Batch Execution Errorsdetails;Cannot change the ExecutorType when t

에러 메시지 : TransientDataAccessResourceException : Batch Execution Errors details <Cannot change the ExecutorType when there is an existing transaction 발생 원인 : batch execution(ExecutorType.BATCH)이 동작 중인데, 중간에 mapper(Executo

choisblog.tistory.com

 

@Repository
public class testMapper {

    @Qualifier("SqlSessionFactory")
    protected SqlSessionFactory sqlSessionFactory;

    public testMapper(SqlSessionFactory sqlSessionFactory) {
        this.sqlSessionFactory = sqlSessionFactory;
    }

    public void updateReqReportTarget(HashMap<String, Object> map) {
        SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
        try {
            sqlSession.update("com.example.batchtest.requestReport.mapper.testMapper.updateReqReportTarget", map);
        } finally {
            sqlSession.commit();
            sqlSession.close();
        }
    }
}

 

@Mapper가 아닌 @Repository를 써야 정상 작동되었다.

 

https://limreus.tistory.com/3

 

[BE/Spring] @Repository 와 @Mapper 비교하기

2021.03.12 최초작성 2023.04.17 수정 @Repository 1) DAO(Data Access Object)나 Repository Bean을 나타내는 데 사용 2) @Repository 어노테이션을 사용하면 해당 클래스가 DB와 상호작용하는 클래스임을 나타낼 수 있음

limreus.tistory.com

https://stackoverflow.com/questions/27996119/what-exactly-is-the-difference-between-a-data-mapper-and-a-repository

 

What exactly is the difference between a data mapper and a repository?

Well I've been trying to find out the difference between data mapper and repository, but up to now I still have not. It seems to me that the expert programmer said "Repository is another layer of

stackoverflow.com

 

 

https://monny.tistory.com/172

 

마이바티스 - insert할 때 주의사항

MyBatis Insert not working insert 구문을 계속 실행시켰지만 데이터베이스에 적용도 안되고 오류도 안나기에 무엇이 잘못된지 한참 찾아다녔다 결론적으로 SqlSession을 commit()시켜주니 적용이 되었는데,

monny.tistory.com

SqlSessionFactory는 autoCommit이 안 되어있어 openSession에 true로 세팅해주거나 commit을 해줘야한다.

'TIL' 카테고리의 다른 글

docker 컨테이너 ip 확인  (0) 2024.03.15
mongoDB object 검색  (0) 2024.02.14
Table 'tableName_seq' doesn't exist, @Slf4j cannot find symbol  (0) 2023.02.17
20221128 JVM의 메모리 모델  (0) 2022.11.28
20221124 NHN FORWARD 후기  (0) 2022.11.24
Comments