/** * Remove all the {@link JobExecution} instances, and all associated * {@link JobInstance} and {@link StepExecution} instances from the standard * RDBMS locations used by Spring Batch. * * @throws DataAccessException if there is a problem */ public void removeJobExecutions() throws DataAccessException { jdbcTemplate.update(getQuery("delete from %PREFIX%STEP_EXECUTION_CONTEXT")); jdbcTemplate.update(getQuery("delete from %PREFIX%STEP_EXECUTION")); jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_EXECUTION_CONTEXT")); jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_EXECUTION_PARAMS")); jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_EXECUTION")); jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_INSTANCE")); }
for (JobExecution jobExecution : list) { List<Long> stepExecutionIds = jdbcTemplate.query( getQuery("select STEP_EXECUTION_ID from %PREFIX%STEP_EXECUTION where JOB_EXECUTION_ID=?"), new RowMapper<Long>() { @Override jdbcTemplate.update(getQuery("delete from %PREFIX%STEP_EXECUTION_CONTEXT where STEP_EXECUTION_ID=?"), stepExecutionId); jdbcTemplate.update(getQuery("delete from %PREFIX%STEP_EXECUTION where STEP_EXECUTION_ID=?"), stepExecutionId); jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_EXECUTION_CONTEXT where JOB_EXECUTION_ID=?"), jobExecution.getId()); jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_EXECUTION_PARAMS where JOB_EXECUTION_ID=?"), jobExecution .getId()); jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_EXECUTION where JOB_EXECUTION_ID=?"), jobExecution .getId()); jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_INSTANCE where JOB_INSTANCE_ID=?"), jobExecution .getJobId());