作家班结束后。弹簧批处理执行中发生错误。 所有读取数据都要回滚,而块数据不会插入数据库。
在步骤执行数据已更新时,提交失败的含义是什么错误"?为什么会出现这个日志?
是作家插入交易的时间问题吗?
如果有一次插入事务(注释到' recordDataService.insertRecordData(recordData);',则没有问题。
我的代码:
@Override
public void write(List<? extends RecordInfo> items) {
log.info("########################################################");
log.info("write");
log.info("########################################################");
recordInfoService.insertRecordInfo(recordInfos.get(0));
for( RecordData recordData : recordInfos.get(0).getRecordDataList()){
recordDataService.insertRecordData(recordData);
}
彼此作家的日志:
2015-07-17 00:05:38.995 INFO 42558 --- [ main] c.s.c.b.j.c.CollectRecordItemWriter : ########################################################
2015-07-17 00:05:38.995 INFO 42558 --- [ main] c.s.c.b.j.c.CollectRecordItemWriter : write
2015-07-17 00:05:38.995 INFO 42558 --- [ main] c.s.c.b.j.c.CollectRecordItemWriter : ########################################################
2015-07-17 16:34:26.921 INFO 41111 --- [ main] o.s.jdbc.support.SQLErrorCodesFactory : SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase, Hana]
2015-07-16 02:30:25.734 INFO 60636 --- [ main] o.s.batch.core.step.tasklet.TaskletStep : Commit failed while step execution data was already updated. Reverting to old version.
执行日志:所有内容都要回滚
+++++++++++++++++++++++++++++++++++++++++++++++++++++
Step collectRecordStep
WriteCount: 0
ReadCount: 14
ReadSkipCount: 0
Commits: 1
SkipCount: 0
Rollbacks: 14
Filter: 0
+++++++++++++++++++++++++++++++++++++++++++++++++++++