Add tests and implement fix for very quick running (<1ms) jobs (incorporating suggestions made)

This commit is contained in:
David Thexton
2012-05-16 12:04:38 +01:00
committed by Dave Syer
parent bea966ce4a
commit 00aab3eafa
7 changed files with 52 additions and 5 deletions

View File

@@ -68,7 +68,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
+ " from %PREFIX%JOB_EXECUTION where JOB_INSTANCE_ID = ? order by JOB_EXECUTION_ID desc";
private static final String GET_LAST_EXECUTION = "SELECT JOB_EXECUTION_ID, START_TIME, END_TIME, STATUS, EXIT_CODE, EXIT_MESSAGE, CREATE_TIME, LAST_UPDATED, VERSION "
+ "from %PREFIX%JOB_EXECUTION where JOB_INSTANCE_ID = ? and CREATE_TIME = (SELECT max(CREATE_TIME) from %PREFIX%JOB_EXECUTION where JOB_INSTANCE_ID = ?)";
+ "from %PREFIX%JOB_EXECUTION E where JOB_INSTANCE_ID = ? and JOB_EXECUTION_ID = (SELECT max(JOB_EXECUTION_ID) from %PREFIX%JOB_EXECUTION E2 where E.JOB_INSTANCE_ID = E2.JOB_INSTANCE_ID)";
private static final String GET_EXECUTION_BY_ID = "SELECT JOB_EXECUTION_ID, START_TIME, END_TIME, STATUS, EXIT_CODE, EXIT_MESSAGE, CREATE_TIME, LAST_UPDATED, VERSION"
+ " from %PREFIX%JOB_EXECUTION where JOB_EXECUTION_ID = ?";
@@ -221,7 +221,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
Long id = jobInstance.getId();
List<JobExecution> executions = getJdbcTemplate().query(getQuery(GET_LAST_EXECUTION),
new JobExecutionRowMapper(jobInstance), id, id);
new JobExecutionRowMapper(jobInstance), id);
Assert.state(executions.size() <= 1, "There must be at most one latest job execution");