작성
·
607
·
수정됨
0
안녕하세요 JdbcCursorItemReader 와 JdbcBatchItemWriter를 이용해 기존 데이터를 변환해서 다른 테이블로 이관하는 테스트를 진행하고 있습니다. 근데 JdbcCursorItemReader 에서 select는 잘되는데 JdbcBatchItemWriter에서 insert쿼리를 날릴때 무한대기 현상이 발생하는거 같습니다.
@Bean
public Job transferDBJob(JobRepository jobRepository, Step transferBookStep){
return new JobBuilder("transferDBJob",jobRepository)
.start(transferBookStep)
.build();
}
@Bean
public Step transferBookStep(JobRepository jobRepository, PlatformTransactionManager tm,
JdbcPagingItemReader<TransSpecies> pagingSpeciesReader, ItemProcessor<TransSpecies, Species> transItemProcessor,
JdbcBatchItemWriter<Species> transItemWriter) {
return new StepBuilder("transferBookStep",jobRepository)
.<TransSpecies,Species>chunk(10,tm)
.reader(pagingSpeciesReader)
.processor(transItemProcessor)
.writer(transItemWriter)
.build();
}
@Bean
public JdbcPagingItemReader<TransSpecies> pagingSpeciesReader(DataSource dataSource,PagingQueryProvider createQueryProvider) {
return new JdbcPagingItemReaderBuilder<TransSpecies>()
.name("transSpeciesReader")
.pageSize(10)
.fetchSize(10)
.dataSource(dataSource)
.rowMapper(new BeanPropertyRowMapper<>(TransSpecies.class))
.queryProvider(createQueryProvider)
.build();
}
@Bean
public PagingQueryProvider createQueryProvider(DataSource dataSource) throws Exception {
SqlPagingQueryProviderFactoryBean queryProvider = new SqlPagingQueryProviderFactoryBean();
queryProvider.setDataSource(dataSource);
queryProvider.setSelectClause("SPECIESKEY,AUTHOR,TITLE");
queryProvider.setFromClause("FROM TRANSSPECIES");
Map<String, Order> sortKeys = new HashMap<>(1);
sortKeys.put("SPECIESKEY", Order.ASCENDING);
queryProvider.setSortKeys(sortKeys);
return queryProvider.getObject();
}
@Bean
public ItemProcessor<TransSpecies,Species> transItemProcessor(){
return transSpecies ->{
Species species = new Species();
species.setRecKey(transSpecies.getSpeciesKey());
species.setTitle(transSpecies.getTitle());
species.setAuthor(transSpecies.getAuthor());
return species;
};
}
@Bean
public JdbcBatchItemWriter<Species> transItemWriter(DataSource dataSource){
return new JdbcBatchItemWriterBuilder<Species>()
.sql("INSERT INTO SPECIES VALUES (:recKey, :author, :title)")
.beanMapped()
.dataSource(dataSource)
.build();
}
현재 작성한 간단하 코드이며
로그에는 현재 이렇게 무한대기 상태에 놓이게 됩니다.
확인 부탁드립니다 ㅠㅠ