Example usage for org.springframework.batch.core JobExecution setId

List of usage examples for org.springframework.batch.core JobExecution setId

Introduction

In this page you can find the example usage for org.springframework.batch.core JobExecution setId.

Prototype

public void setId(Long id) 

Source Link

Usage

From source file:org.trpr.platform.batch.impl.spring.admin.repository.MapJobExecutionDao.java

@Override
public void saveJobExecution(JobExecution jobExecution) {
    Assert.isTrue(jobExecution.getId() == null);
    Long newId = currentId.getAndIncrement();
    jobExecution.setId(newId);
    jobExecution.incrementVersion();// ww  w  .  j a  va  2  s .c  om
    this.addNewExecution(newId, copy(jobExecution));
}

From source file:org.springframework.batch.core.repository.dao.JdbcJobExecutionDao.java

/**
 *
 * SQL implementation using Sequences via the Spring incrementer
 * abstraction. Once a new id has been obtained, the JobExecution is saved
 * via a SQL INSERT statement./*from   w  w w  .j a v a 2  s  .  com*/
 *
 * @see JobExecutionDao#saveJobExecution(JobExecution)
 * @throws IllegalArgumentException if jobExecution is null, as well as any
 * of it's fields to be persisted.
 */
@Override
public void saveJobExecution(JobExecution jobExecution) {

    validateJobExecution(jobExecution);

    jobExecution.incrementVersion();

    jobExecution.setId(jobExecutionIncrementer.nextLongValue());
    Object[] parameters = new Object[] { jobExecution.getId(), jobExecution.getJobId(),
            jobExecution.getStartTime(), jobExecution.getEndTime(), jobExecution.getStatus().toString(),
            jobExecution.getExitStatus().getExitCode(), jobExecution.getExitStatus().getExitDescription(),
            jobExecution.getVersion(), jobExecution.getCreateTime(), jobExecution.getLastUpdated(),
            jobExecution.getJobConfigurationName() };
    getJdbcTemplate().update(getQuery(SAVE_JOB_EXECUTION), parameters,
            new int[] { Types.BIGINT, Types.BIGINT, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR,
                    Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.TIMESTAMP, Types.TIMESTAMP,
                    Types.VARCHAR });

    insertJobParameters(jobExecution.getId(), jobExecution.getJobParameters());
}