diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/BatchRegistrar.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/BatchRegistrar.java index dce11d25d..6b296bbfc 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/BatchRegistrar.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/BatchRegistrar.java @@ -35,6 +35,7 @@ import org.springframework.context.annotation.ImportBeanDefinitionRegistrar; import org.springframework.core.log.LogMessage; import org.springframework.core.type.AnnotationMetadata; import org.springframework.util.StopWatch; +import org.springframework.util.StringUtils; /** * Base registrar that provides common infrastructure beans for enabling and using Spring @@ -135,6 +136,11 @@ class BatchRegistrar implements ImportBeanDefinitionRegistrar { beanDefinitionBuilder.addPropertyValue("isolationLevelForCreate", isolationLevelForCreate); } + String databaseType = batchAnnotation.databaseType(); + if (StringUtils.hasText(databaseType)) { + beanDefinitionBuilder.addPropertyValue("databaseType", databaseType); + } + beanDefinitionBuilder.addPropertyValue("maxVarCharLength", batchAnnotation.maxVarCharLength()); beanDefinitionBuilder.addPropertyValue("clobType", batchAnnotation.clobType()); registry.registerBeanDefinition("jobRepository", beanDefinitionBuilder.getBeanDefinition()); diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.java b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.java index dfeed20d5..301d160b6 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.java @@ -32,6 +32,7 @@ import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.launch.support.TaskExecutorJobLauncher; import org.springframework.batch.core.repository.JobRepository; import org.springframework.batch.core.repository.dao.AbstractJdbcBatchMetadataDao; +import org.springframework.batch.support.DatabaseType; import org.springframework.context.annotation.Import; import org.springframework.transaction.PlatformTransactionManager; @@ -179,6 +180,15 @@ public @interface EnableBatchProcessing { */ String dataSourceRef() default "dataSource"; + /** + * Set the type of the data source to use in the job repository. The default type will + * be introspected from the datasource's metadata. + * @since 5.1 + * @see DatabaseType + * @return the type of data source. + */ + String databaseType() default ""; + /** * Set the transaction manager to use in the job repository. * @return the bean name of the transaction manager to use. Defaults to