diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java b/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java index 2ce6ae2c9b..0fbd4147f8 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/StepExecution.java @@ -61,7 +61,9 @@ public class StepExecution extends Entity { private volatile long writeSkipCount = 0; - private volatile Date startTime = new Date(System.currentTimeMillis()); + private volatile Date startTime = null; + + private volatile Date createTime = new Date(System.currentTimeMillis()); private volatile Date endTime = null; @@ -248,6 +250,24 @@ public void setRollbackCount(long rollbackCount) { this.rollbackCount = rollbackCount; } + /** + * Gets the time this execution was created + * + * @return the time when this execution was created. + */ + public Date getCreateTime() { + return createTime; + } + + /** + * Sets the time this execution was created + * + * @param createTime creation time of this execution. + */ + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + /** * Gets the time this execution started * diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java index 2d001f81cf..a4aee020c9 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java @@ -72,7 +72,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement private static final String SAVE_STEP_EXECUTION = "INSERT into %PREFIX%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(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + "ROLLBACK_COUNT, LAST_UPDATED, CREATE_TIME) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; private static final String UPDATE_STEP_EXECUTION = "UPDATE %PREFIX%STEP_EXECUTION set START_TIME = ?, END_TIME = ?, " + "STATUS = ?, COMMIT_COUNT = ?, READ_COUNT = ?, FILTER_COUNT = ?, WRITE_COUNT = ?, EXIT_CODE = ?, " @@ -82,8 +82,8 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement private static final String GET_RAW_STEP_EXECUTIONS = "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 %PREFIX%STEP_EXECUTION " + - "where JOB_EXECUTION_ID = ?"; + "WRITE_SKIP_COUNT, PROCESS_SKIP_COUNT, ROLLBACK_COUNT, LAST_UPDATED, VERSION, CREATE_TIME from " + + "%PREFIX%STEP_EXECUTION where JOB_EXECUTION_ID = ?"; private static final String GET_STEP_EXECUTIONS = GET_RAW_STEP_EXECUTIONS + " order by STEP_EXECUTION_ID"; @@ -92,14 +92,14 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement private static final String GET_LAST_STEP_EXECUTION = "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," + + "SE.WRITE_SKIP_COUNT, SE.PROCESS_SKIP_COUNT, SE.ROLLBACK_COUNT, SE.LAST_UPDATED, SE.VERSION, SE.CREATE_TIME," + " 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 %PREFIX%JOB_EXECUTION JE join %PREFIX%STEP_EXECUTION SE" + " on SE.JOB_EXECUTION_ID = JE.JOB_EXECUTION_ID " + "where JE.JOB_INSTANCE_ID = ?" + " and SE.STEP_NAME = ?" + - " order by SE.START_TIME desc, SE.STEP_EXECUTION_ID desc"; + " order by SE.CREATE_TIME desc, SE.STEP_EXECUTION_ID desc"; private static final String CURRENT_VERSION_STEP_EXECUTION = "SELECT VERSION FROM %PREFIX%STEP_EXECUTION WHERE " + "STEP_EXECUTION_ID=?"; @@ -221,18 +221,18 @@ private List buildStepExecutionParameters(StepExecution stepExecution) stepExecution.getReadCount(), stepExecution.getFilterCount(), stepExecution.getWriteCount(), stepExecution.getExitStatus().getExitCode(), exitDescription, stepExecution.getReadSkipCount(), stepExecution.getWriteSkipCount(), stepExecution.getProcessSkipCount(), - stepExecution.getRollbackCount(), stepExecution.getLastUpdated() }; + stepExecution.getRollbackCount(), stepExecution.getLastUpdated(), stepExecution.getCreateTime() }; Integer[] parameterTypes = new Integer[] { Types.BIGINT, Types.INTEGER, Types.VARCHAR, Types.BIGINT, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.VARCHAR, Types.VARCHAR, Types.BIGINT, Types.BIGINT, Types.BIGINT, - Types.BIGINT, Types.TIMESTAMP }; + Types.BIGINT, Types.TIMESTAMP, Types.TIMESTAMP }; parameters.add(0, Arrays.copyOf(parameterValues,parameterValues.length)); parameters.add(1, Arrays.copyOf(parameterTypes,parameterTypes.length)); return parameters; } /** - * Validate StepExecution. At a minimum, JobId, StartTime, and Status cannot + * Validate StepExecution. At a minimum, JobId, CreateTime, and Status cannot * be null. EndTime can be null for an unfinished job. * * @throws IllegalArgumentException @@ -240,7 +240,7 @@ private List buildStepExecutionParameters(StepExecution stepExecution) private void validateStepExecution(StepExecution stepExecution) { Assert.notNull(stepExecution, "stepExecution is required"); Assert.notNull(stepExecution.getStepName(), "StepExecution step name cannot be null."); - Assert.notNull(stepExecution.getStartTime(), "StepExecution start time cannot be null."); + Assert.notNull(stepExecution.getCreateTime(), "StepExecution create time cannot be null."); Assert.notNull(stepExecution.getStatus(), "StepExecution status cannot be null."); } @@ -327,15 +327,15 @@ public StepExecution getLastStepExecution(JobInstance jobInstance, String stepNa List executions = getJdbcTemplate().query( getQuery(GET_LAST_STEP_EXECUTION), (rs, rowNum) -> { - Long jobExecutionId = rs.getLong(18); + Long jobExecutionId = rs.getLong(19); JobExecution jobExecution = new JobExecution(jobExecutionId); - jobExecution.setStartTime(rs.getTimestamp(19)); - jobExecution.setEndTime(rs.getTimestamp(20)); - jobExecution.setStatus(BatchStatus.valueOf(rs.getString(21))); - jobExecution.setExitStatus(new ExitStatus(rs.getString(22), rs.getString(23))); - jobExecution.setCreateTime(rs.getTimestamp(24)); - jobExecution.setLastUpdated(rs.getTimestamp(25)); - jobExecution.setVersion(rs.getInt(26)); + jobExecution.setStartTime(rs.getTimestamp(20)); + jobExecution.setEndTime(rs.getTimestamp(21)); + jobExecution.setStatus(BatchStatus.valueOf(rs.getString(22))); + jobExecution.setExitStatus(new ExitStatus(rs.getString(23), rs.getString(24))); + jobExecution.setCreateTime(rs.getTimestamp(25)); + jobExecution.setLastUpdated(rs.getTimestamp(26)); + jobExecution.setVersion(rs.getInt(27)); return new StepExecutionRowMapper(jobExecution).mapRow(rs, rowNum); }, jobInstance.getInstanceId(), stepName); @@ -382,6 +382,7 @@ public StepExecution mapRow(ResultSet rs, int rowNum) throws SQLException { stepExecution.setRollbackCount(rs.getInt(15)); stepExecution.setLastUpdated(rs.getTimestamp(16)); stepExecution.setVersion(rs.getInt(17)); + stepExecution.setCreateTime(rs.getTimestamp(18)); return stepExecution; } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/StepExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/StepExecutionDao.java index 107b44e717..8e7b4f4766 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/StepExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/StepExecutionDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2020 the original author or authors. + * Copyright 2006-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,7 +68,7 @@ public interface StepExecutionDao { /** * Retrieve the last {@link StepExecution} for a given {@link JobInstance} - * ordered by starting time and then id. + * ordered by creation time and then id. * * @param jobInstance the parent {@link JobInstance} * @param stepName the name of the step diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-db2.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-db2.sql new file mode 100644 index 0000000000..110d4660d7 --- /dev/null +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-db2.sql @@ -0,0 +1,2 @@ +ALTER TABLE BATCH_STEP_EXECUTION ADD CREATE_TIME TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00'; +ALTER TABLE BATCH_STEP_EXECUTION ALTER COLUMN START_TIME DROP NOT NULL; \ No newline at end of file diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-derby.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-derby.sql new file mode 100644 index 0000000000..110d4660d7 --- /dev/null +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-derby.sql @@ -0,0 +1,2 @@ +ALTER TABLE BATCH_STEP_EXECUTION ADD CREATE_TIME TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00'; +ALTER TABLE BATCH_STEP_EXECUTION ALTER COLUMN START_TIME DROP NOT NULL; \ No newline at end of file diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-h2.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-h2.sql new file mode 100644 index 0000000000..110d4660d7 --- /dev/null +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-h2.sql @@ -0,0 +1,2 @@ +ALTER TABLE BATCH_STEP_EXECUTION ADD CREATE_TIME TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00'; +ALTER TABLE BATCH_STEP_EXECUTION ALTER COLUMN START_TIME DROP NOT NULL; \ No newline at end of file diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-hsqldb.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-hsqldb.sql new file mode 100644 index 0000000000..177a319dc6 --- /dev/null +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-hsqldb.sql @@ -0,0 +1,2 @@ +ALTER TABLE BATCH_STEP_EXECUTION ADD CREATE_TIME TIMESTAMP DEFAULT '1970-01-01 00:00:00' NOT NULL; +ALTER TABLE BATCH_STEP_EXECUTION ALTER COLUMN START_TIME DROP NOT NULL; \ No newline at end of file diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-mysql.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-mysql.sql new file mode 100644 index 0000000000..8a8e1fd26a --- /dev/null +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-mysql.sql @@ -0,0 +1,2 @@ +ALTER TABLE BATCH_STEP_EXECUTION ADD CREATE_TIME DATETIME(6) NOT NULL DEFAULT '1970-01-01 00:00:00'; +ALTER TABLE BATCH_STEP_EXECUTION MODIFY START_TIME DATETIME(6) NULL; \ No newline at end of file diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-oracle.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-oracle.sql index 6e41e36b56..2003fcbe50 100644 --- a/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-oracle.sql +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-oracle.sql @@ -1,3 +1,6 @@ ALTER SEQUENCE BATCH_STEP_EXECUTION_SEQ ORDER; ALTER SEQUENCE BATCH_JOB_EXECUTION_SEQ ORDER; -ALTER SEQUENCE BATCH_JOB_SEQ ORDER; \ No newline at end of file +ALTER SEQUENCE BATCH_JOB_SEQ ORDER; + +ALTER TABLE BATCH_STEP_EXECUTION ADD CREATE_TIME TIMESTAMP DEFAULT TO_TIMESTAMP('1970-01-01 00:00:00', 'yyyy-MM-dd HH24:mi:ss') NOT NULL; +ALTER TABLE BATCH_STEP_EXECUTION MODIFY START_TIME TIMESTAMP NULL; \ No newline at end of file diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-postgresql.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-postgresql.sql new file mode 100644 index 0000000000..110d4660d7 --- /dev/null +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-postgresql.sql @@ -0,0 +1,2 @@ +ALTER TABLE BATCH_STEP_EXECUTION ADD CREATE_TIME TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00'; +ALTER TABLE BATCH_STEP_EXECUTION ALTER COLUMN START_TIME DROP NOT NULL; \ No newline at end of file diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-sqlserver.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-sqlserver.sql index 8f2cc0671a..b333d28b45 100644 --- a/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-sqlserver.sql +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-sqlserver.sql @@ -1,2 +1,5 @@ ALTER TABLE BATCH_STEP_EXECUTION_CONTEXT ALTER COLUMN SERIALIZED_CONTEXT VARCHAR(MAX) NULL; -ALTER TABLE BATCH_JOB_EXECUTION_CONTEXT ALTER COLUMN SERIALIZED_CONTEXT VARCHAR(MAX) NULL; \ No newline at end of file +ALTER TABLE BATCH_JOB_EXECUTION_CONTEXT ALTER COLUMN SERIALIZED_CONTEXT VARCHAR(MAX) NULL; + +ALTER TABLE BATCH_STEP_EXECUTION ADD CREATE_TIME DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'; +ALTER TABLE BATCH_STEP_EXECUTION ALTER COLUMN START_TIME DATETIME NULL; \ No newline at end of file diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-sybase.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-sybase.sql new file mode 100644 index 0000000000..74bd8b437f --- /dev/null +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/migration/5.0/migration-sybase.sql @@ -0,0 +1,3 @@ +ALTER TABLE BATCH_STEP_EXECUTION ADD CREATE_TIME DATETIME DEFAULT '1970-01-01 00:00:00' NOT NULL; +ALTER TABLE BATCH_STEP_EXECUTION MODIFY START_TIME DATETIME NULL; +?? \ No newline at end of file diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-db2.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-db2.sql index ac4e0b6e20..aacfac621c 100644 --- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-db2.sql +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-db2.sql @@ -41,7 +41,8 @@ CREATE TABLE BATCH_STEP_EXECUTION ( VERSION BIGINT NOT NULL, STEP_NAME VARCHAR(100) NOT NULL, JOB_EXECUTION_ID BIGINT NOT NULL, - START_TIME TIMESTAMP NOT NULL , + CREATE_TIME TIMESTAMP NOT NULL, + START_TIME TIMESTAMP DEFAULT NULL , END_TIME TIMESTAMP DEFAULT NULL , STATUS VARCHAR(10) , COMMIT_COUNT BIGINT , diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-derby.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-derby.sql index 2f70cd6e0c..5d3d560a1d 100644 --- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-derby.sql +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-derby.sql @@ -41,7 +41,8 @@ CREATE TABLE BATCH_STEP_EXECUTION ( VERSION BIGINT NOT NULL, STEP_NAME VARCHAR(100) NOT NULL, JOB_EXECUTION_ID BIGINT NOT NULL, - START_TIME TIMESTAMP NOT NULL , + CREATE_TIME TIMESTAMP NOT NULL, + START_TIME TIMESTAMP DEFAULT NULL , END_TIME TIMESTAMP DEFAULT NULL , STATUS VARCHAR(10) , COMMIT_COUNT BIGINT , diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-h2.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-h2.sql index 8c78e9a0da..7fb837e6bf 100644 --- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-h2.sql +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-h2.sql @@ -41,7 +41,8 @@ CREATE TABLE BATCH_STEP_EXECUTION ( VERSION BIGINT NOT NULL, STEP_NAME VARCHAR(100) NOT NULL, JOB_EXECUTION_ID BIGINT NOT NULL, - START_TIME TIMESTAMP NOT NULL , + CREATE_TIME TIMESTAMP NOT NULL, + START_TIME TIMESTAMP DEFAULT NULL , END_TIME TIMESTAMP DEFAULT NULL , STATUS VARCHAR(10) , COMMIT_COUNT BIGINT , diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-hsqldb.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-hsqldb.sql index 297fd08454..75dcc2fd1d 100644 --- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-hsqldb.sql +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-hsqldb.sql @@ -41,7 +41,8 @@ CREATE TABLE BATCH_STEP_EXECUTION ( VERSION BIGINT NOT NULL, STEP_NAME VARCHAR(100) NOT NULL, JOB_EXECUTION_ID BIGINT NOT NULL, - START_TIME TIMESTAMP NOT NULL , + CREATE_TIME TIMESTAMP NOT NULL , + START_TIME TIMESTAMP DEFAULT NULL , END_TIME TIMESTAMP DEFAULT NULL , STATUS VARCHAR(10) , COMMIT_COUNT BIGINT , diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-mysql.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-mysql.sql index a6b805ecc7..026ea3891f 100644 --- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-mysql.sql +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-mysql.sql @@ -41,7 +41,8 @@ CREATE TABLE BATCH_STEP_EXECUTION ( VERSION BIGINT NOT NULL, STEP_NAME VARCHAR(100) NOT NULL, JOB_EXECUTION_ID BIGINT NOT NULL, - START_TIME DATETIME(6) NOT NULL , + CREATE_TIME DATETIME(6) NOT NULL, + START_TIME DATETIME(6) DEFAULT NULL , END_TIME DATETIME(6) DEFAULT NULL , STATUS VARCHAR(10) , COMMIT_COUNT BIGINT , diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-oracle.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-oracle.sql index 2e8c6dbe7c..4f0154e3c6 100644 --- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-oracle.sql +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-oracle.sql @@ -41,7 +41,8 @@ CREATE TABLE BATCH_STEP_EXECUTION ( VERSION NUMBER(19,0) NOT NULL, STEP_NAME VARCHAR2(100 char) NOT NULL, JOB_EXECUTION_ID NUMBER(19,0) NOT NULL, - START_TIME TIMESTAMP NOT NULL , + CREATE_TIME TIMESTAMP NOT NULL, + START_TIME TIMESTAMP DEFAULT NULL , END_TIME TIMESTAMP DEFAULT NULL , STATUS VARCHAR2(10 char) , COMMIT_COUNT NUMBER(19,0) , diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-postgresql.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-postgresql.sql index acfaefca71..35bc5918d4 100644 --- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-postgresql.sql +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-postgresql.sql @@ -41,7 +41,8 @@ CREATE TABLE BATCH_STEP_EXECUTION ( VERSION BIGINT NOT NULL, STEP_NAME VARCHAR(100) NOT NULL, JOB_EXECUTION_ID BIGINT NOT NULL, - START_TIME TIMESTAMP NOT NULL , + CREATE_TIME TIMESTAMP NOT NULL, + START_TIME TIMESTAMP DEFAULT NULL , END_TIME TIMESTAMP DEFAULT NULL , STATUS VARCHAR(10) , COMMIT_COUNT BIGINT , diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlite.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlite.sql index 0ca50c5d3c..89164a0847 100644 --- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlite.sql +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlite.sql @@ -41,7 +41,8 @@ CREATE TABLE BATCH_STEP_EXECUTION ( VERSION INTEGER NOT NULL, STEP_NAME VARCHAR(100) NOT NULL, JOB_EXECUTION_ID INTEGER NOT NULL, - START_TIME TIMESTAMP NOT NULL , + CREATE_TIME TIMESTAMP NOT NULL, + START_TIME TIMESTAMP DEFAULT NULL , END_TIME TIMESTAMP DEFAULT NULL , STATUS VARCHAR(10) , COMMIT_COUNT INTEGER , diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlserver.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlserver.sql index 1b7c2c2bb8..b8562341bb 100644 --- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlserver.sql +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sqlserver.sql @@ -41,7 +41,8 @@ CREATE TABLE BATCH_STEP_EXECUTION ( VERSION BIGINT NOT NULL, STEP_NAME VARCHAR(100) NOT NULL, JOB_EXECUTION_ID BIGINT NOT NULL, - START_TIME DATETIME NOT NULL , + CREATE_TIME DATETIME NOT NULL, + START_TIME DATETIME DEFAULT NULL , END_TIME DATETIME DEFAULT NULL , STATUS VARCHAR(10) NULL, COMMIT_COUNT BIGINT NULL, diff --git a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sybase.sql b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sybase.sql index 073ef1358f..f2afc8e91a 100644 --- a/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sybase.sql +++ b/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-sybase.sql @@ -41,7 +41,8 @@ CREATE TABLE BATCH_STEP_EXECUTION ( VERSION BIGINT NOT NULL, STEP_NAME VARCHAR(100) NOT NULL, JOB_EXECUTION_ID BIGINT NOT NULL, - START_TIME DATETIME NOT NULL , + CREATE_TIME DATETIME NOT NULL, + START_TIME DATETIME DEFAULT NULL NULL, END_TIME DATETIME DEFAULT NULL NULL, STATUS VARCHAR(10) NULL, COMMIT_COUNT BIGINT NULL, diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/StepExecutionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/StepExecutionTests.java index 97626b2e3e..1513cc1df0 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/StepExecutionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/StepExecutionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2021 the original author or authors. + * Copyright 2006-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,13 +75,13 @@ public void testGetEndTime() { /** * Test method for - * {@link org.springframework.batch.core.JobExecution#getStartTime()}. + * {@link StepExecution#getCreateTime()}. */ @Test - public void testGetStartTime() { - assertNotNull(execution.getStartTime()); - execution.setStartTime(new Date(10L)); - assertEquals(10L, execution.getStartTime().getTime()); + public void testGetCreateTime() { + assertNotNull(execution.getCreateTime()); + execution.setCreateTime(new Date(10L)); + assertEquals(10L, execution.getCreateTime().getTime()); } /** diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java index 5640a83a55..67d826a2f9 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2021 the original author or authors. + * Copyright 2006-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -335,5 +335,6 @@ private void assertStepExecutionsAreEqual(StepExecution expected, StepExecution assertEquals(expected.getLastUpdated(), actual.getLastUpdated()); assertEquals(expected.getExitStatus(), actual.getExitStatus()); assertEquals(expected.getJobExecutionId(), actual.getJobExecutionId()); + assertEquals(expected.getCreateTime(), actual.getCreateTime()); } } diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/repository/dao/schema-prefix-hsqldb.sql b/spring-batch-core/src/test/resources/org/springframework/batch/core/repository/dao/schema-prefix-hsqldb.sql index 857fe21917..72a8fc0917 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/repository/dao/schema-prefix-hsqldb.sql +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/repository/dao/schema-prefix-hsqldb.sql @@ -50,7 +50,8 @@ CREATE TABLE PREFIX_STEP_EXECUTION ( VERSION BIGINT NOT NULL, STEP_NAME VARCHAR(100) NOT NULL, JOB_EXECUTION_ID BIGINT NOT NULL, - START_TIME TIMESTAMP NOT NULL , + CREATE_TIME TIMESTAMP NOT NULL , + START_TIME TIMESTAMP DEFAULT NULL , END_TIME TIMESTAMP DEFAULT NULL , STATUS VARCHAR(10) , COMMIT_COUNT BIGINT , diff --git a/spring-batch-core/src/test/resources/org/springframework/batch/core/schema-hsqldb-extended.sql b/spring-batch-core/src/test/resources/org/springframework/batch/core/schema-hsqldb-extended.sql index 66959b5e19..e2fe276e46 100644 --- a/spring-batch-core/src/test/resources/org/springframework/batch/core/schema-hsqldb-extended.sql +++ b/spring-batch-core/src/test/resources/org/springframework/batch/core/schema-hsqldb-extended.sql @@ -45,7 +45,8 @@ CREATE TABLE BATCH_STEP_EXECUTION ( VERSION BIGINT NOT NULL, STEP_NAME VARCHAR(100) NOT NULL, JOB_EXECUTION_ID BIGINT NOT NULL, - START_TIME TIMESTAMP NOT NULL , + CREATE_TIME TIMESTAMP NOT NULL , + START_TIME TIMESTAMP DEFAULT NULL , END_TIME TIMESTAMP DEFAULT NULL , STATUS VARCHAR(10) , COMMIT_COUNT BIGINT ,