org.springframework.batch.core.repository.dao
Class JdbcJobExecutionDao

java.lang.Object
  extended by org.springframework.batch.core.repository.dao.AbstractJdbcBatchMetadataDao
      extended by org.springframework.batch.core.repository.dao.JdbcJobExecutionDao
All Implemented Interfaces:
JobExecutionDao, InitializingBean

public class JdbcJobExecutionDao
extends AbstractJdbcBatchMetadataDao
implements JobExecutionDao, InitializingBean

Jdbc implementation of JobExecutionDao. Uses sequences (via Spring's DataFieldMaxValueIncrementer abstraction) to create all primary keys before inserting a new row. Objects are checked to ensure all mandatory 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

Field Summary
 
Fields inherited from class org.springframework.batch.core.repository.dao.AbstractJdbcBatchMetadataDao
DEFAULT_EXIT_MESSAGE_LENGTH, DEFAULT_TABLE_PREFIX
 
Constructor Summary
JdbcJobExecutionDao()
           
 
Method Summary
 void afterPropertiesSet()
           
 ExecutionContext findExecutionContext(JobExecution jobExecution)
          Find the ExecutionContext for the given JobExecution.
 List findJobExecutions(JobInstance job)
          Return list of JobExecutions for given JobInstance.
 int getJobExecutionCount(JobInstance jobInstance)
          Return the number of JobExecutions for the given JobInstance Preconditions: jobInstance must have an id.
 JobExecution getLastJobExecution(JobInstance jobInstance)
           
 void saveJobExecution(JobExecution jobExecution)
          SQL implementation using Sequences via the Spring incrementer abstraction.
 void saveOrUpdateExecutionContext(JobExecution jobExecution)
          Save the ExecutionContext of the given JobExecution.
 void setExitMessageLength(int exitMessageLength)
          Public setter for the exit message length in database.
 void setJobExecutionIncrementer(DataFieldMaxValueIncrementer jobExecutionIncrementer)
          Setter for DataFieldMaxValueIncrementer to be used when generating primary keys for JobExecution instances.
 void setLobHandler(LobHandler lobHandler)
           
 void updateJobExecution(JobExecution jobExecution)
          Update given JobExecution using a SQL UPDATE statement.
 
Methods inherited from class org.springframework.batch.core.repository.dao.AbstractJdbcBatchMetadataDao
getJdbcTemplate, getQuery, getTablePrefix, setJdbcTemplate, setTablePrefix
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbcJobExecutionDao

public JdbcJobExecutionDao()
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

findJobExecutions

public List findJobExecutions(JobInstance job)
Description copied from interface: JobExecutionDao
Return list of JobExecutions for given JobInstance.

Specified by:
findJobExecutions in interface JobExecutionDao
Returns:
list of jobExecutions.

getJobExecutionCount

public int getJobExecutionCount(JobInstance jobInstance)
Description copied from interface: JobExecutionDao
Return the number of JobExecutions for the given JobInstance Preconditions: jobInstance must have an id.

Specified by:
getJobExecutionCount in interface JobExecutionDao
Throws:
IllegalArgumentException - if jobId is null.
See Also:
JobExecutionDao.getJobExecutionCount(JobInstance)

saveJobExecution

public void saveJobExecution(JobExecution jobExecution)
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.

Specified by:
saveJobExecution in interface JobExecutionDao
Throws:
IllegalArgumentException - if jobExecution is null, as well as any of it's fields to be persisted.
See Also:
JobExecutionDao.saveJobExecution(JobExecution)

updateJobExecution

public void updateJobExecution(JobExecution jobExecution)
Update given JobExecution using a SQL UPDATE statement. The JobExecution is first checked to ensure all fields are not null, and that it has an ID. The database is then queried to ensure that the ID exists, which ensures that it is valid.

Specified by:
updateJobExecution in interface JobExecutionDao
See Also:
JobExecutionDao.updateJobExecution(JobExecution)

setJobExecutionIncrementer

public void setJobExecutionIncrementer(DataFieldMaxValueIncrementer jobExecutionIncrementer)
Setter for DataFieldMaxValueIncrementer to be used when generating primary keys for JobExecution instances.

Parameters:
jobExecutionIncrementer - the DataFieldMaxValueIncrementer

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Overrides:
afterPropertiesSet in class AbstractJdbcBatchMetadataDao
Throws:
Exception

getLastJobExecution

public JobExecution getLastJobExecution(JobInstance jobInstance)
Specified by:
getLastJobExecution in interface JobExecutionDao
Returns:
last JobExecution for given JobInstance.

findExecutionContext

public ExecutionContext findExecutionContext(JobExecution jobExecution)
Description copied from interface: JobExecutionDao
Find the ExecutionContext for the given JobExecution.

Specified by:
findExecutionContext in interface JobExecutionDao

saveOrUpdateExecutionContext

public void saveOrUpdateExecutionContext(JobExecution jobExecution)
Description copied from interface: JobExecutionDao
Save the ExecutionContext of the given JobExecution.

Specified by:
saveOrUpdateExecutionContext in interface JobExecutionDao
Parameters:
jobExecution - the JobExecution containing the ExecutionContext to be saved.

setLobHandler

public void setLobHandler(LobHandler lobHandler)


Copyright © 2009 SpringSource. All Rights Reserved.