org.springframework.batch.core.repository.dao

## Class JdbcStepExecutionDao

- java.lang.Object
- - org.springframework.batch.core.repository.dao.AbstractJdbcBatchMetadataDao
  - - org.springframework.batch.core.repository.dao.JdbcStepExecutionDao

- All Implemented Interfaces:
    StepExecutionDao, org.springframework.beans.factory.InitializingBean

      public class JdbcStepExecutionDao
      extends AbstractJdbcBatchMetadataDao
      implements StepExecutionDao, org.springframework.beans.factory.InitializingBean

  JDBC implementation of `StepExecutionDao`.
  Allows customization of the tables names used by Spring Batch for step meta data via a prefix property.
  Uses sequences or tables (via Spring's `DataFieldMaxValueIncrementer` abstraction) to create all primary keys before inserting a new row. All objects are checked to ensure all fields to be stored are not null. If any are found to be null, an IllegalArgumentException will be thrown. This could be left to JdbcTemplate, however, the exception will be fairly vague, and fails to highlight which field caused the exception.
  Author:
    Lucas Ward, Dave Syer, Robert Kasanicky, David Turanski, Mahmoud Ben Hassine
  See Also:
    `StepExecutionDao`

- - ### Field Summary

    - ### Fields inherited from class org.springframework.batch.core.repository.dao.AbstractJdbcBatchMetadataDao

      `DEFAULT_EXIT_MESSAGE_LENGTH, DEFAULT_TABLE_PREFIX`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JdbcStepExecutionDao()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addStepExecutions(JobExecution jobExecution)` Retrieve all the `StepExecution` for the parent `JobExecution`.
    `void` | `afterPropertiesSet()`
    `StepExecution` | `getLastStepExecution(JobInstance jobInstance, java.lang.String stepName)` Retrieve the last `StepExecution` for a given `JobInstance` ordered by starting time and then id.
    `StepExecution` | `getStepExecution(JobExecution jobExecution, java.lang.Long stepExecutionId)` Retrieve a `StepExecution` from its id.
    `void` | `saveStepExecution(StepExecution stepExecution)` Save a StepExecution.
    `void` | `saveStepExecutions(java.util.Collection<StepExecution> stepExecutions)` Batch insert StepExecutions
    `void` | `setExitMessageLength(int exitMessageLength)` Public setter for the exit message length in database.
    `void` | `setStepExecutionIncrementer(org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer stepExecutionIncrementer)`
    `void` | `updateStepExecution(StepExecution stepExecution)` Update the given StepExecution Preconditions: Id must not be null.

    - ### Methods inherited from class org.springframework.batch.core.repository.dao.AbstractJdbcBatchMetadataDao

      `getClobTypeToUse, getJdbcTemplate, getQuery, getTablePrefix, setClobTypeToUse, setJdbcTemplate, setTablePrefix`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### JdbcStepExecutionDao

          public JdbcStepExecutionDao()

  - ### Method Detail

    - #### setExitMessageLength

          public void setExitMessageLength(int exitMessageLength)

      Public setter for the exit message length in database. Do not set this if you haven't modified the schema.
      Parameters:
        `exitMessageLength` - the exitMessageLength to set

    - #### setStepExecutionIncrementer

          public void setStepExecutionIncrementer(org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer stepExecutionIncrementer)

    - #### afterPropertiesSet

          public void afterPropertiesSet()
                                  throws java.lang.Exception

      Specified by:
        `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`
      Overrides:
        `afterPropertiesSet` in class `AbstractJdbcBatchMetadataDao`
      Throws:
        `java.lang.Exception`

    - #### saveStepExecution

          public void saveStepExecution(StepExecution stepExecution)

      Save a StepExecution. A unique id will be generated by the stepExecutionIncrementer, and then set in the StepExecution. All values will then be stored via an INSERT statement.
      Specified by:
        `saveStepExecution` in interface `StepExecutionDao`
      Parameters:
        `stepExecution` - `StepExecution` instance to be saved.
      See Also:
        `StepExecutionDao.saveStepExecution(StepExecution)`

    - #### saveStepExecutions

          public void saveStepExecutions(java.util.Collection<StepExecution> stepExecutions)

      Batch insert StepExecutions
      Specified by:
        `saveStepExecutions` in interface `StepExecutionDao`
      Parameters:
        `stepExecutions` - a collection of `JobExecution` instances to be saved.
      See Also:
        `StepExecutionDao.saveStepExecutions(Collection)`

    - #### updateStepExecution

          public void updateStepExecution(StepExecution stepExecution)

      Description copied from interface: `StepExecutionDao`
      Update the given StepExecution Preconditions: Id must not be null.
      Specified by:
        `updateStepExecution` in interface `StepExecutionDao`
      Parameters:
        `stepExecution` - `StepExecution` instance to be updated.

    - #### getStepExecution

          @Nullable
          public StepExecution getStepExecution(JobExecution jobExecution,
                                                          java.lang.Long stepExecutionId)

      Description copied from interface: `StepExecutionDao`
      Retrieve a `StepExecution` from its id.
      Specified by:
        `getStepExecution` in interface `StepExecutionDao`
      Parameters:
        `jobExecution` - the parent `JobExecution`
        `stepExecutionId` - the step execution id
      Returns:
        a `StepExecution`

    - #### getLastStepExecution

          public StepExecution getLastStepExecution(JobInstance jobInstance,
                                                    java.lang.String stepName)

      Description copied from interface: `StepExecutionDao`
      Retrieve the last `StepExecution` for a given `JobInstance` ordered by starting time and then id.
      Specified by:
        `getLastStepExecution` in interface `StepExecutionDao`
      Parameters:
        `jobInstance` - the parent `JobInstance`
        `stepName` - the name of the step
      Returns:
        a `StepExecution`

    - #### addStepExecutions

          public void addStepExecutions(JobExecution jobExecution)

      Description copied from interface: `StepExecutionDao`
      Retrieve all the `StepExecution` for the parent `JobExecution`.
      Specified by:
        `addStepExecutions` in interface `StepExecutionDao`
      Parameters:
        `jobExecution` - the parent job execution