Add support to specify the database type with EnableBatchProcessing
Resolves #4320
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user