Class JdbcJobExecutionDao
java.lang.Object
org.springframework.batch.core.repository.dao.AbstractJdbcBatchMetadataDao
org.springframework.batch.core.repository.dao.JdbcJobExecutionDao
- All Implemented Interfaces:
JobExecutionDao,org.springframework.beans.factory.InitializingBean
public class JdbcJobExecutionDao
extends AbstractJdbcBatchMetadataDao
implements JobExecutionDao, org.springframework.beans.factory.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, Michael Minella, Mahmoud Ben Hassine, Dimitrios Liapis, Philippe Marschall, Jinwoo Bae
-
Field Summary
Fields inherited from class org.springframework.batch.core.repository.dao.AbstractJdbcBatchMetadataDao
DEFAULT_EXIT_MESSAGE_LENGTH, DEFAULT_SHORT_CONTEXT_LENGTH, DEFAULT_TABLE_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoiddeleteJobExecution(JobExecution jobExecution) Delete the given job execution.voiddeleteJobExecutionParameters(JobExecution jobExecution) Delete the parameters associated with the given job execution.Return allJobExecutions for givenJobInstance, sorted backwards by creation order (so the first element is the most recent).findRunningJobExecutions(String jobName) getJobExecution(Long executionId) protected JobParametersgetJobParameters(Long executionId) getLastJobExecution(JobInstance jobInstance) Find the lastJobExecutionto have been created for a givenJobInstance.voidsaveJobExecution(JobExecution jobExecution) SQL implementation using Sequences via the Spring incrementer abstraction.voidsetConversionService(org.springframework.core.convert.support.ConfigurableConversionService conversionService) Set the conversion service to use to convert job parameters from String literals to typed values and vice versa.voidsetExitMessageLength(int exitMessageLength) Public setter for the exit message length in database.voidsetJobExecutionIncrementer(org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer jobExecutionIncrementer) Setter forDataFieldMaxValueIncrementerto be used when generating primary keys forJobExecutioninstances.voidsynchronizeStatus(JobExecution jobExecution) Because it may be possible that the status of a JobExecution is updated while running, the following method will synchronize only the status and version fields.voidupdateJobExecution(JobExecution jobExecution) Update given JobExecution using a SQL UPDATE statement.Methods inherited from class org.springframework.batch.core.repository.dao.AbstractJdbcBatchMetadataDao
getClobTypeToUse, getJdbcTemplate, getQuery, getTablePrefix, setClobTypeToUse, setJdbcTemplate, setTablePrefix
-
Constructor Details
-
JdbcJobExecutionDao
public JdbcJobExecutionDao()
-
-
Method Details
-
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
-
setJobExecutionIncrementer
public void setJobExecutionIncrementer(org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer jobExecutionIncrementer) Setter forDataFieldMaxValueIncrementerto be used when generating primary keys forJobExecutioninstances.- Parameters:
jobExecutionIncrementer- theDataFieldMaxValueIncrementer
-
setConversionService
public void setConversionService(@NonNull org.springframework.core.convert.support.ConfigurableConversionService conversionService) Set the conversion service to use to convert job parameters from String literals to typed values and vice versa. -
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Overrides:
afterPropertiesSetin classAbstractJdbcBatchMetadataDao- Throws:
Exception
-
findJobExecutions
Description copied from interface:JobExecutionDaoReturn allJobExecutions for givenJobInstance, sorted backwards by creation order (so the first element is the most recent).- Specified by:
findJobExecutionsin interfaceJobExecutionDao- Parameters:
job- parentJobInstanceof theJobExecutions to find.- Returns:
Listcontaining JobExecutions for the jobInstance.
-
saveJobExecution
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:
saveJobExecutionin interfaceJobExecutionDao- Parameters:
jobExecution-JobExecutioninstance to be saved.- Throws:
IllegalArgumentException- if jobExecution is null, as well as any of it's fields to be persisted.- See Also:
-
updateJobExecution
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:
updateJobExecutionin interfaceJobExecutionDao- Parameters:
jobExecution-JobExecutioninstance to be updated.- See Also:
-
getLastJobExecution
Description copied from interface:JobExecutionDaoFind the lastJobExecutionto have been created for a givenJobInstance.- Specified by:
getLastJobExecutionin interfaceJobExecutionDao- Parameters:
jobInstance- theJobInstance- Returns:
- the last
JobExecutionto execute for this instance ornullif no job execution is found for the given job instance.
-
getJobExecution
- Specified by:
getJobExecutionin interfaceJobExecutionDao- Parameters:
executionId-Longcontaining the id of the execution.- Returns:
- the
JobExecutionfor given identifier.
-
findRunningJobExecutions
- Specified by:
findRunningJobExecutionsin interfaceJobExecutionDao- Parameters:
jobName-Stringcontaining the name of the job.- Returns:
- all
JobExecutionthat are still running (or indeterminate state), i.e. having null end date, for the specified job name.
-
synchronizeStatus
Description copied from interface:JobExecutionDaoBecause it may be possible that the status of a JobExecution is updated while running, the following method will synchronize only the status and version fields.- Specified by:
synchronizeStatusin interfaceJobExecutionDao- Parameters:
jobExecution- to be updated.
-
deleteJobExecution
Delete the given job execution.- Specified by:
deleteJobExecutionin interfaceJobExecutionDao- Parameters:
jobExecution- the job execution to delete
-
deleteJobExecutionParameters
Delete the parameters associated with the given job execution.- Specified by:
deleteJobExecutionParametersin interfaceJobExecutionDao- Parameters:
jobExecution- the job execution for which job parameters should be deleted
-
getJobParameters
- Parameters:
executionId-Longcontaining the id for the execution.- Returns:
- job parameters for the requested execution id
-