英文:
Spring Batch JPA SaveALL() and SAVE() not working and no Error
问题
I wrote the code, but the jpa is not saved. select statement works but save or saveall doesn't. No way to solve it?
Existing batches except for commercial work well, but only the newly created commercial step does not work.
Below is the corresponding code.
BatchConfiguration.java
@Configuration
@RequiredArgsConstructor
@EnableBatchProcessing
public class BatchConfiguration extends DefaultBatchConfigurer{
// ... (other beans and configurations)
@Bean(name = "commercialJob")
public Job commercialJob() {
return jobBuilderFactory.get("commercial")
.incrementer(new RunIdIncrementer())
.flow(commercialStep())
.end()
.build();
}
@Bean
public Step commercialStep() {
return stepBuilderFactory.get(StepState.COMMERCIAL.toString())
.<List<AdPoiDto>, List<AdPoiDto>>chunk(CHUNK_SIZE)
.reader(commercialReader)
.writer(adpoiWriter)
.build();
}
// ... (other steps and configurations)
}
AdpoiWriter.java
@Slf4j
@RequiredArgsConstructor
@StepScope
@Component
public class AdpoiWriter implements ItemWriter<List<AdPoiDto>>{
// ... (other fields and methods)
@Override
public void write(List<? extends List<AdPoiDto>> adPoiDtos) {
List<AdPoi> adPoiList = new ArrayList<>();
ObjectMapper objectMapper = new ObjectMapper();
for (List<AdPoiDto> dtoList : adPoiDtos) {
for (AdPoiDto dto : dtoList) {
AdPoi adPoi = objectMapper.convertValue(dto, AdPoi.class);
adPoiList.add(adPoi);
}
}
advertisementCommercialRepository.saveAll(adPoiList); // This should save all AdPoi entities
log.info("@@@ Insert ad_poi End");
}
}
Based on the provided code, it seems that you have configured a batch job named "commercialJob" with a step named "commercialStep," and within the "commercialStep," you are using the adpoiWriter
to save a list of AdPoi
entities to the database using advertisementCommercialRepository.saveAll(adPoiList);
. If this is not working as expected, here are a few suggestions to check:
-
Transaction Management: Ensure that the transaction management is correctly set up. You mentioned that you tried using
JPATransactionManager
but it failed. You need to make sure that the transactions are being managed properly. If there is an issue with transaction management, it could prevent the changes from being persisted in the database. -
Error Handling: Check for any error messages or exceptions in your logs. If there is an error during the save operation, it should be logged, and you can investigate the error message to identify the issue.
-
Database Connection: Ensure that your application has a valid and active database connection. If the connection to the database is lost or not properly configured, it can prevent data from being saved.
-
Database Configuration: Verify that your database configuration is correct, including the entity mappings and database schema. Ensure that the
AdPoi
entity is properly annotated with JPA annotations and mapped to the correct database table. -
Data Validity: Make sure that the data you are trying to save is valid and does not violate any constraints or validations in your database schema.
-
QueryDSL: You mentioned that your project uses QueryDSL. Ensure that your QueryDSL queries are correct and not causing any issues with the save operation.
-
Logging: If you are not seeing any errors in the logs, consider adding additional logging statements to your code to trace the flow of execution and check if the save operation is being reached and if the data being saved is as expected.
Without specific error messages or more detailed information, it's challenging to pinpoint the exact cause of the issue. I recommend reviewing the above points and checking your application logs for any error messages or exceptions that might provide more insights into why the save operation is not working as expected.
英文:
I wrote the code, but the jpa is not saved. select statement works but save or saveall doesn't. No way to solve it?
Existing batches except for commercial work well, but only the newly created commercial step does not work.
Below is the corresponding code.
BatchConfiguration.java
@Configuration
@RequiredArgsConstructor
@EnableBatchProcessing
public class BatchConfiguration extends DefaultBatchConfigurer{
private final Integer CHUNK_SIZE = 1;
private final JobBuilderFactory jobBuilderFactory;
private final StepBuilderFactory stepBuilderFactory;
// Call Step
private final CallLogReader callLogReader;
private final CallLogStatisticsWriter callLogStatisticsWriter;
// Click Step
private final ClickLogReader clickLogReader;
private final ClickLogStatisticsWriter clickLogStatisticsWriter;
// Exposure Step
private final ExposureLogReader exposureLogReader;
private final ExposureAdvertisementLogStatisticsWriter exposureAdvertisementLogStatisticsWriter;
private final ExposureChannelLogStatisticsWriter exposureChannelLogStatisticsWriter;
private final ExposureVendorLogStatisticsWriter exposureVendorLogStatisticsWriter;
private final ExposureLogStatisticsWrtier exposureLogStatisticsWrtier;
// Search Step
private final SearchLogReader searchLogReader;
private final SearchAdministrationLogStatisticsWriter searchAdministrationLogStatisticsWriter;
private final SearchProspectLogStatisticsWriter searchProspectLogStatisticsWriter;
// AdvertieseCommercial Step
private final CommercialReader commercialReader;
private final AdpoiWriter adpoiWriter;
// @Autowired(required = true)
// private JpaTransactionManager transactionManager;
@Bean(name = "callJob")
public Job callJob() {
return jobBuilderFactory.get("call")
.incrementer(new RunIdIncrementer())
.flow(callStep())
.end()
.build();
}
@Bean(name = "clickJob")
public Job clickJob() {
return jobBuilderFactory.get("click")
.incrementer(new RunIdIncrementer())
.flow(clickStep())
.end()
.build();
}
@Bean(name = "exposureJob")
public Job exposureJob() {
return jobBuilderFactory.get("exposure")
.incrementer(new RunIdIncrementer())
.flow(exposureStep())
.end()
.build();
}
// 가망 통계
@Bean(name = "searchJob")
public Job searchJob() {
return jobBuilderFactory.get("search")
.incrementer(new RunIdIncrementer())
.flow(searchStep())
.end()
.build();
}
//네스 data 저장
@Bean(name = "commercialJob")
public Job commercialJob() {
return jobBuilderFactory.get("commercial")
.incrementer(new RunIdIncrementer())
.flow(commercialStep())
.end()
.build();
}
@Bean
public Step callStep() {
return stepBuilderFactory.get(StepState.CALL.toString())
.<List<CallStatistics>, List<CallStatistics>> chunk(CHUNK_SIZE)
.reader(callLogReader)
.writer(callLogStatisticsWriter)
.build();
}
@Bean
public Step clickStep() {
return stepBuilderFactory.get(StepState.CLICK.toString())
.<List<ClickStatistics>,List<ClickStatistics>> chunk(CHUNK_SIZE)
.reader(clickLogReader)
.writer(clickLogStatisticsWriter)
.build();
}
@Bean
public Step exposureStep() {
return stepBuilderFactory.get(StepState.EXPOSURE.toString())
.<ExposureDto, ExposureDto >chunk(CHUNK_SIZE)
.reader(exposureLogReader)
.writer(compositeExposureLogStatisticsWriters())
.build();
}
@Bean
public Step searchStep() {
return stepBuilderFactory.get(StepState.SEARCH.toString())
.<SearchDto, SearchDto >chunk(CHUNK_SIZE)
.reader(searchLogReader)
.writer(compositeSearchLogStatisticsWriters())
.build();
}
@Bean
public Step commercialStep() {
return stepBuilderFactory.get(StepState.COMMERCIAL.toString())
.<List<AdPoiDto>, List<AdPoiDto>>chunk(CHUNK_SIZE)
.reader(commercialReader)
.writer(adpoiWriter)
// .transactionManager(transactionManager)
.build();
}
@Bean
public CompositeItemWriter<ExposureDto> compositeExposureLogStatisticsWriters() {
CompositeItemWriter<ExposureDto> compositeItemWriter = new CompositeItemWriter<>();
compositeItemWriter.setDelegates(Arrays.asList(exposureAdvertisementLogStatisticsWriter,
exposureChannelLogStatisticsWriter, exposureLogStatisticsWrtier, exposureVendorLogStatisticsWriter));
return compositeItemWriter;
}
@Bean
public CompositeItemWriter<SearchDto> compositeSearchLogStatisticsWriters() {
CompositeItemWriter<SearchDto> compositeItemWriter = new CompositeItemWriter<>();
compositeItemWriter.setDelegates(Arrays.asList(searchAdministrationLogStatisticsWriter,
searchProspectLogStatisticsWriter));
return compositeItemWriter;
}
}
writer
@Slf4j
@RequiredArgsConstructor
@StepScope
@Component
public class AdpoiWriter implements ItemWriter<List<AdPoiDto>>{
@Autowired
private final AdvertisementCommercialRepository advertisementCommercialRepository;
@Override
public void write(List<? extends List<AdPoiDto>> adPoiDtos) {
List<AdPoi> adPoiList = new ArrayList<>();
ObjectMapper objectMapper = new ObjectMapper();
for (List<AdPoiDto> dtoList : adPoiDtos) {
for (AdPoiDto dto : dtoList) {
AdPoi adPoi = objectMapper.convertValue(dto, AdPoi.class);
adPoiList.add(adPoi);
}
}
// AdPoi adPoi = new AdPoi();
// System.out.println("@@@@ : Adpoi : " + adPoiList.get(0));
// advertisementCommercialRepository.save(adPoi);
// advertisementCommercialRepository.insertData(adPoiList.get(0).getOp_cl(), adPoiList.get(0).getTelno_cl());
advertisementCommercialRepository.saveAll(adPoiList);
// Iterable<AdPoi> adPois = advertisementCommercialRepository.findAll();
// for (AdPoi adPoi : adPois) {
// System.out.println("@@@ 11234" + adPoi.toString());
// }
log.info("@@@ Insert ad_poi End");
}
}
Terminal log that appears when the batch is executed
2023-06-22 10:22:58.213 INFO 23995 --- [nio-8084-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-06-22 10:22:58.214 INFO 23995 --- [nio-8084-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2023-06-22 10:22:58.274 INFO 23995 --- [nio-8084-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 60 ms
@@@@ 2023-06-21
2023-06-22 10:22:58.579 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL query
2023-06-22 10:22:58.581 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ?]
2023-06-22 10:22:58.673 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL query
2023-06-22 10:22:58.674 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ?]
2023-06-22 10:22:58.693 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL query
2023-06-22 10:22:58.693 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ?]
2023-06-22 10:22:58.769 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL update
2023-06-22 10:22:58.775 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [INSERT into BATCH_JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION) values (?, ?, ?, ?)]
2023-06-22 10:22:58.841 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL update
2023-06-22 10:22:58.842 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [INSERT into BATCH_JOB_EXECUTION(JOB_EXECUTION_ID, JOB_INSTANCE_ID, START_TIME, END_TIME, STATUS, EXIT_CODE, EXIT_MESSAGE, VERSION, CREATE_TIME, LAST_UPDATED, JOB_CONFIGURATION_LOCATION) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]
2023-06-22 10:22:58.865 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL update
2023-06-22 10:22:58.872 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [INSERT into BATCH_JOB_EXECUTION_PARAMS(JOB_EXECUTION_ID, KEY_NAME, TYPE_CD, STRING_VAL, DATE_VAL, LONG_VAL, DOUBLE_VAL, IDENTIFYING) values (?, ?, ?, ?, ?, ?, ?, ?)]
2023-06-22 10:22:58.910 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL update
2023-06-22 10:22:58.911 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [INSERT INTO BATCH_JOB_EXECUTION_CONTEXT (SHORT_CONTEXT, SERIALIZED_CONTEXT, JOB_EXECUTION_ID) VALUES(?, ?, ?)]
2023-06-22 10:22:58.959 INFO 23995 --- [ryBean_Worker-1] o.s.b.c.l.support.SimpleJobLauncher : Job: [FlowJob: [name=commercial]] launched with the following parameters: [{TIME=1687310578370}]
2023-06-22 10:22:58.998 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL query
2023-06-22 10:22:58.998 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT VERSION FROM BATCH_JOB_EXECUTION WHERE JOB_EXECUTION_ID=?]
2023-06-22 10:22:59.019 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL query
2023-06-22 10:22:59.019 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT COUNT(*) FROM BATCH_JOB_EXECUTION WHERE JOB_EXECUTION_ID = ?]
2023-06-22 10:22:59.037 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL update
2023-06-22 10:22:59.039 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [UPDATE BATCH_JOB_EXECUTION set START_TIME = ?, END_TIME = ?, STATUS = ?, EXIT_CODE = ?, EXIT_MESSAGE = ?, VERSION = ?, CREATE_TIME = ?, LAST_UPDATED = ? where JOB_EXECUTION_ID = ? and VERSION = ?]
2023-06-22 10:22:59.093 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL query
2023-06-22 10:22:59.093 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT JOB_EXECUTION_ID, START_TIME, END_TIME, STATUS, EXIT_CODE, EXIT_MESSAGE, CREATE_TIME, LAST_UPDATED, VERSION, JOB_CONFIGURATION_LOCATION from BATCH_JOB_EXECUTION where JOB_INSTANCE_ID = ? order by JOB_EXECUTION_ID desc]
2023-06-22 10:22:59.103 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL query
2023-06-22 10:22:59.103 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT JOB_EXECUTION_ID, KEY_NAME, TYPE_CD, STRING_VAL, DATE_VAL, LONG_VAL, DOUBLE_VAL, IDENTIFYING from BATCH_JOB_EXECUTION_PARAMS where JOB_EXECUTION_ID = ?]
2023-06-22 10:22:59.136 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL query
2023-06-22 10:22:59.136 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT STEP_EXECUTION_ID, STEP_NAME, START_TIME, END_TIME, STATUS, COMMIT_COUNT, READ_COUNT, FILTER_COUNT, WRITE_COUNT, EXIT_CODE, EXIT_MESSAGE, READ_SKIP_COUNT, WRITE_SKIP_COUNT, PROCESS_SKIP_COUNT, ROLLBACK_COUNT, LAST_UPDATED, VERSION from BATCH_STEP_EXECUTION where JOB_EXECUTION_ID = ? order by STEP_EXECUTION_ID]
2023-06-22 10:22:59.186 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL query
2023-06-22 10:22:59.186 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT SE.STEP_EXECUTION_ID, SE.STEP_NAME, SE.START_TIME, SE.END_TIME, SE.STATUS, SE.COMMIT_COUNT, SE.READ_COUNT, SE.FILTER_COUNT, SE.WRITE_COUNT, SE.EXIT_CODE, SE.EXIT_MESSAGE, SE.READ_SKIP_COUNT, SE.WRITE_SKIP_COUNT, SE.PROCESS_SKIP_COUNT, SE.ROLLBACK_COUNT, SE.LAST_UPDATED, SE.VERSION, JE.JOB_EXECUTION_ID, JE.START_TIME, JE.END_TIME, JE.STATUS, JE.EXIT_CODE, JE.EXIT_MESSAGE, JE.CREATE_TIME, JE.LAST_UPDATED, JE.VERSION from BATCH_JOB_EXECUTION JE, BATCH_STEP_EXECUTION SE where SE.JOB_EXECUTION_ID in (SELECT JOB_EXECUTION_ID from BATCH_JOB_EXECUTION where JOB_INSTANCE_ID = ?) and SE.JOB_EXECUTION_ID = JE.JOB_EXECUTION_ID and SE.STEP_NAME = ? order by SE.START_TIME desc, SE.STEP_EXECUTION_ID desc]
2023-06-22 10:22:59.236 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL query
2023-06-22 10:22:59.236 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT JOB_EXECUTION_ID, START_TIME, END_TIME, STATUS, EXIT_CODE, EXIT_MESSAGE, CREATE_TIME, LAST_UPDATED, VERSION, JOB_CONFIGURATION_LOCATION from BATCH_JOB_EXECUTION where JOB_INSTANCE_ID = ? order by JOB_EXECUTION_ID desc]
2023-06-22 10:22:59.245 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL query
2023-06-22 10:22:59.245 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT JOB_EXECUTION_ID, KEY_NAME, TYPE_CD, STRING_VAL, DATE_VAL, LONG_VAL, DOUBLE_VAL, IDENTIFYING from BATCH_JOB_EXECUTION_PARAMS where JOB_EXECUTION_ID = ?]
2023-06-22 10:22:59.273 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL query
2023-06-22 10:22:59.273 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT STEP_EXECUTION_ID, STEP_NAME, START_TIME, END_TIME, STATUS, COMMIT_COUNT, READ_COUNT, FILTER_COUNT, WRITE_COUNT, EXIT_CODE, EXIT_MESSAGE, READ_SKIP_COUNT, WRITE_SKIP_COUNT, PROCESS_SKIP_COUNT, ROLLBACK_COUNT, LAST_UPDATED, VERSION from BATCH_STEP_EXECUTION where JOB_EXECUTION_ID = ? order by STEP_EXECUTION_ID]
2023-06-22 10:22:59.371 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL update
2023-06-22 10:22:59.371 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [INSERT into BATCH_STEP_EXECUTION(STEP_EXECUTION_ID, VERSION, STEP_NAME, JOB_EXECUTION_ID, START_TIME, END_TIME, STATUS, COMMIT_COUNT, READ_COUNT, FILTER_COUNT, WRITE_COUNT, EXIT_CODE, EXIT_MESSAGE, READ_SKIP_COUNT, WRITE_SKIP_COUNT, PROCESS_SKIP_COUNT, ROLLBACK_COUNT, LAST_UPDATED) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]
2023-06-22 10:22:59.394 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL update
2023-06-22 10:22:59.395 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [INSERT INTO BATCH_STEP_EXECUTION_CONTEXT (SHORT_CONTEXT, SERIALIZED_CONTEXT, STEP_EXECUTION_ID) VALUES(?, ?, ?)]
2023-06-22 10:22:59.431 INFO 23995 --- [ryBean_Worker-1] o.s.batch.core.job.SimpleStepHandler : Executing step: [COMMERCIAL]
2023-06-22 10:22:59.439 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL update
2023-06-22 10:22:59.439 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [UPDATE BATCH_STEP_EXECUTION set START_TIME = ?, END_TIME = ?, STATUS = ?, COMMIT_COUNT = ?, READ_COUNT = ?, FILTER_COUNT = ?, WRITE_COUNT = ?, EXIT_CODE = ?, EXIT_MESSAGE = ?, VERSION = ?, READ_SKIP_COUNT = ?, PROCESS_SKIP_COUNT = ?, WRITE_SKIP_COUNT = ?, ROLLBACK_COUNT = ?, LAST_UPDATED = ? where STEP_EXECUTION_ID = ? and VERSION = ?]
2023-06-22 10:22:59.456 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL query
2023-06-22 10:22:59.456 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT VERSION FROM BATCH_JOB_EXECUTION WHERE JOB_EXECUTION_ID=?]
2023-06-22 10:22:59.554 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL update
2023-06-22 10:22:59.554 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [UPDATE BATCH_STEP_EXECUTION_CONTEXT SET SHORT_CONTEXT = ?, SERIALIZED_CONTEXT = ? WHERE STEP_EXECUTION_ID = ?]
2023-06-22 10:22:59.626 INFO 23995 --- [ryBean_Worker-1] c.z.w.m.b.s.c.CommercialReader : Commercial Batch START
2023-06-22 10:22:59.626 INFO 23995 --- [ryBean_Worker-1] c.z.w.m.b.s.c.CommercialReader : Commercial STEP DATE : 2023-06-21
2023-06-22 10:23:00.408 INFO 23995 --- [ryBean_Worker-1] c.z.w.m.b.s.c.c.AdpoiWriter : @@@ Insert ad_poi End
2023-06-22 10:23:00.413 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL update
2023-06-22 10:23:00.413 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [UPDATE BATCH_STEP_EXECUTION_CONTEXT SET SHORT_CONTEXT = ?, SERIALIZED_CONTEXT = ? WHERE STEP_EXECUTION_ID = ?]
2023-06-22 10:23:00.436 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL update
2023-06-22 10:23:00.436 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [UPDATE BATCH_STEP_EXECUTION set START_TIME = ?, END_TIME = ?, STATUS = ?, COMMIT_COUNT = ?, READ_COUNT = ?, FILTER_COUNT = ?, WRITE_COUNT = ?, EXIT_CODE = ?, EXIT_MESSAGE = ?, VERSION = ?, READ_SKIP_COUNT = ?, PROCESS_SKIP_COUNT = ?, WRITE_SKIP_COUNT = ?, ROLLBACK_COUNT = ?, LAST_UPDATED = ? where STEP_EXECUTION_ID = ? and VERSION = ?]
2023-06-22 10:23:00.454 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL query
2023-06-22 10:23:00.454 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT VERSION FROM BATCH_JOB_EXECUTION WHERE JOB_EXECUTION_ID=?]
2023-06-22 10:23:00.502 INFO 23995 --- [ryBean_Worker-1] c.z.w.m.b.s.c.CommercialReader : Commercial Batch START
2023-06-22 10:23:00.502 INFO 23995 --- [ryBean_Worker-1] c.z.w.m.b.s.c.CommercialReader : Commercial STEP DATE : 2023-06-21
2023-06-22 10:23:00.502 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL update
2023-06-22 10:23:00.502 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [UPDATE BATCH_STEP_EXECUTION_CONTEXT SET SHORT_CONTEXT = ?, SERIALIZED_CONTEXT = ? WHERE STEP_EXECUTION_ID = ?]
2023-06-22 10:23:00.520 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL update
2023-06-22 10:23:00.521 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [UPDATE BATCH_STEP_EXECUTION set START_TIME = ?, END_TIME = ?, STATUS = ?, COMMIT_COUNT = ?, READ_COUNT = ?, FILTER_COUNT = ?, WRITE_COUNT = ?, EXIT_CODE = ?, EXIT_MESSAGE = ?, VERSION = ?, READ_SKIP_COUNT = ?, PROCESS_SKIP_COUNT = ?, WRITE_SKIP_COUNT = ?, ROLLBACK_COUNT = ?, LAST_UPDATED = ? where STEP_EXECUTION_ID = ? and VERSION = ?]
2023-06-22 10:23:00.537 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL query
2023-06-22 10:23:00.538 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT VERSION FROM BATCH_JOB_EXECUTION WHERE JOB_EXECUTION_ID=?]
2023-06-22 10:23:00.587 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL update
2023-06-22 10:23:00.587 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [UPDATE BATCH_STEP_EXECUTION_CONTEXT SET SHORT_CONTEXT = ?, SERIALIZED_CONTEXT = ? WHERE STEP_EXECUTION_ID = ?]
2023-06-22 10:23:00.619 INFO 23995 --- [ryBean_Worker-1] o.s.batch.core.step.AbstractStep : Step: [COMMERCIAL] executed in 1s188ms
2023-06-22 10:23:00.627 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL update
2023-06-22 10:23:00.627 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [UPDATE BATCH_STEP_EXECUTION set START_TIME = ?, END_TIME = ?, STATUS = ?, COMMIT_COUNT = ?, READ_COUNT = ?, FILTER_COUNT = ?, WRITE_COUNT = ?, EXIT_CODE = ?, EXIT_MESSAGE = ?, VERSION = ?, READ_SKIP_COUNT = ?, PROCESS_SKIP_COUNT = ?, WRITE_SKIP_COUNT = ?, ROLLBACK_COUNT = ?, LAST_UPDATED = ? where STEP_EXECUTION_ID = ? and VERSION = ?]
2023-06-22 10:23:00.645 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL query
2023-06-22 10:23:00.645 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT VERSION FROM BATCH_JOB_EXECUTION WHERE JOB_EXECUTION_ID=?]
2023-06-22 10:23:00.692 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL update
2023-06-22 10:23:00.692 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [UPDATE BATCH_JOB_EXECUTION_CONTEXT SET SHORT_CONTEXT = ?, SERIALIZED_CONTEXT = ? WHERE JOB_EXECUTION_ID = ?]
2023-06-22 10:23:00.740 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL query
2023-06-22 10:23:00.741 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT VERSION FROM BATCH_JOB_EXECUTION WHERE JOB_EXECUTION_ID=?]
2023-06-22 10:23:00.760 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL query
2023-06-22 10:23:00.760 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT COUNT(*) FROM BATCH_JOB_EXECUTION WHERE JOB_EXECUTION_ID = ?]
2023-06-22 10:23:00.777 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL update
2023-06-22 10:23:00.777 DEBUG 23995 --- [ryBean_Worker-1] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [UPDATE BATCH_JOB_EXECUTION set START_TIME = ?, END_TIME = ?, STATUS = ?, EXIT_CODE = ?, EXIT_MESSAGE = ?, VERSION = ?, CREATE_TIME = ?, LAST_UPDATED = ? where JOB_EXECUTION_ID = ? and VERSION = ?]
2023-06-22 10:23:00.817 INFO 23995 --- [ryBean_Worker-1] o.s.b.c.l.support.SimpleJobLauncher : Job: [FlowJob: [name=commercial]] completed with the following parameters: [{TIME=1687310578370}] and the following status: [COMPLETED] in 1s743ms
2023-06-22 10:23:00.818 INFO 23995 --- [ryBean_Worker-1] c.z.w.m.b.q.QuartzJobLauncher : Status : COMPLETED
DB uses only one instance,
There are no newly overridden methods in the Repository.
It's not a project I made, it's a module pattern project, and this project uses querydsl. Maybe it has something to do with why querydsl doesn't work?
I tried using JPATransactionManager as well, but it failed.
Hope jpa save() or saveall() will work
答案1
得分: 0
你需要使用 JpaTransactionManager
,但你说过 我也尝试使用 JPATransactionManager,但失败了。
你没有分享你如何尝试的细节,但由于你的类扩展了 DefaultBatchConfigurer
,期望是你要覆盖 getTransactionManager
方法并返回一个 JpaTransactionManager
。
英文:
You need to use a JpaTransactionManager
, but you said I tried using JPATransactionManager as well, but it failed.
You did not share how you tried that, but since your class extends DefaultBatchConfigurer
, the expectation is that you override the getTransacctionManager
method and return a JpaTransactionManager
.
答案2
得分: 0
感谢Mahmoud Ben Hassine的回答,我通过添加以下代码来解决了这个问题:
@Autowired
private final DataSource dataSource;
@Autowired
private final EntityManagerFactory entityManagerFactory;
@Override
public PlatformTransactionManager getTransactionManager() {
return new JpaTransactionManager(entityManagerFactory);
}
英文:
Thanks to Mahmoud Ben Hassine's answer, I solved it by adding that code.
@Autowired
private final DataSource dataSource;
@Autowired
private final EntityManagerFactory entityManagerFactory;
@Override
public PlatformTransactionManager getTransactionManager() {
return new JpaTransactionManager(entityManagerFactory);
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论