Skip to content

Commit

Permalink
Add support to specify the database type with EnableBatchProcessing
Browse files Browse the repository at this point in the history
Resolves #4320
  • Loading branch information
fmbenhassine committed Sep 18, 2023
1 parent f64d6e8 commit 69c6839
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
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
Expand Down Expand Up @@ -135,6 +136,11 @@ private void registerJobRepository(BeanDefinitionRegistry registry, EnableBatchP
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
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;

Expand Down Expand Up @@ -179,6 +180,15 @@
*/
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
Expand Down

0 comments on commit 69c6839

Please sign in to comment.