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_TABLE_PREFIX
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
deleteJobExecution
(JobExecution jobExecution) Delete the given job execution.void
deleteJobExecutionParameters
(JobExecution jobExecution) Delete the parameters associated with the given job execution.Return allJobExecution
s for givenJobInstance
, sorted backwards by creation order (so the first element is the most recent).findRunningJobExecutions
(String jobName) getJobExecution
(Long executionId) protected JobParameters
getJobParameters
(Long executionId) getLastJobExecution
(JobInstance jobInstance) Find the lastJobExecution
to have been created for a givenJobInstance
.void
saveJobExecution
(JobExecution jobExecution) SQL implementation using Sequences via the Spring incrementer abstraction.void
setConversionService
(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.void
setExitMessageLength
(int exitMessageLength) Public setter for the exit message length in database.void
setJobExecutionIncrementer
(org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer jobExecutionIncrementer) Setter forDataFieldMaxValueIncrementer
to be used when generating primary keys forJobExecution
instances.void
synchronizeStatus
(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.void
updateJobExecution
(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 forDataFieldMaxValueIncrementer
to be used when generating primary keys forJobExecution
instances.- 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:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Overrides:
afterPropertiesSet
in classAbstractJdbcBatchMetadataDao
- Throws:
Exception
-
findJobExecutions
Description copied from interface:JobExecutionDao
Return allJobExecution
s for givenJobInstance
, sorted backwards by creation order (so the first element is the most recent).- Specified by:
findJobExecutions
in interfaceJobExecutionDao
- Parameters:
job
- parentJobInstance
of theJobExecution
s to find.- Returns:
List
containing 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:
saveJobExecution
in interfaceJobExecutionDao
- Parameters:
jobExecution
-JobExecution
instance 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:
updateJobExecution
in interfaceJobExecutionDao
- Parameters:
jobExecution
-JobExecution
instance to be updated.- See Also:
-
getLastJobExecution
Description copied from interface:JobExecutionDao
Find the lastJobExecution
to have been created for a givenJobInstance
.- Specified by:
getLastJobExecution
in interfaceJobExecutionDao
- Parameters:
jobInstance
- theJobInstance
- Returns:
- the last
JobExecution
to execute for this instance ornull
if no job execution is found for the given job instance.
-
getJobExecution
- Specified by:
getJobExecution
in interfaceJobExecutionDao
- Parameters:
executionId
-Long
containing the id of the execution.- Returns:
- the
JobExecution
for given identifier.
-
findRunningJobExecutions
- Specified by:
findRunningJobExecutions
in interfaceJobExecutionDao
- Parameters:
jobName
-String
containing the name of the job.- Returns:
- all
JobExecution
that are still running (or indeterminate state), i.e. having null end date, for the specified job name.
-
synchronizeStatus
Description copied from interface:JobExecutionDao
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.- Specified by:
synchronizeStatus
in interfaceJobExecutionDao
- Parameters:
jobExecution
- to be updated.
-
deleteJobExecution
Delete the given job execution.- Specified by:
deleteJobExecution
in interfaceJobExecutionDao
- Parameters:
jobExecution
- the job execution to delete
-
deleteJobExecutionParameters
Delete the parameters associated with the given job execution.- Specified by:
deleteJobExecutionParameters
in interfaceJobExecutionDao
- Parameters:
jobExecution
- the job execution for which job parameters should be deleted
-
getJobParameters
- Parameters:
executionId
-Long
containing the id for the execution.- Returns:
- job parameters for the requested execution id
-