Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,13 @@ public void updateJobExecution(JobExecution jobExecution) {
@Override
public JobExecution getLastJobExecution(JobInstance jobInstance) {
long jobInstanceId = jobInstance.getId();

Long lastJobExecutionId = getJdbcTemplate().queryForObject(getQuery(GET_LAST_JOB_EXECUTION_ID), Long.class,
jobInstanceId, jobInstanceId);

return lastJobExecutionId != null ? getJobExecution(lastJobExecutionId) : null;
try {
Long lastJobExecutionId = getJdbcTemplate().queryForObject(getQuery(GET_LAST_JOB_EXECUTION_ID), Long.class, jobInstanceId, jobInstanceId);
return lastJobExecutionId != null ? getJobExecution(lastJobExecutionId) : null;
}
catch (EmptyResultDataAccessException e) {
return null;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,16 @@ void testGetLastJobExecution() {
assertEquals("jobKey", lastExecution.getJobParameters().getString("job.key"));
}

@Test
void testGetLastJobExecutionNoExecution() {

jobExecutionDao.deleteJobExecution(jobExecution);

JobExecution je = jobExecutionDao.getLastJobExecution(jobInstance);

assertNull(je);
}

/**
* Trying to create instance twice for the same job+parameters causes error
*/
Expand Down