Change transaction manager type in default batch configuration
This commits changes the type of the transaction manager from `DataSourceTransactionManager` to `JdbcTransactionManager` in the default configuration of `@EnableBatchProcessing`. The `JdbcTransactionManager` adds common JDBC exception translation which is beneficial for Spring Batch to improve exception handling and error reporting. Resolves #4126
This commit is contained in:
@@ -43,7 +43,7 @@ import org.springframework.batch.item.support.ListItemReader;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.integration.core.MessagingTemplate;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.jdbc.support.JdbcTransactionManager;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -82,7 +82,7 @@ public class ChunkMessageItemWriterIntegrationTests {
|
||||
EmbeddedDatabase embeddedDatabase = new EmbeddedDatabaseBuilder().generateUniqueName(true)
|
||||
.addScript("/org/springframework/batch/core/schema-drop-hsqldb.sql")
|
||||
.addScript("/org/springframework/batch/core/schema-hsqldb.sql").build();
|
||||
DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(embeddedDatabase);
|
||||
JdbcTransactionManager transactionManager = new JdbcTransactionManager(embeddedDatabase);
|
||||
JobRepositoryFactoryBean repositoryFactoryBean = new JobRepositoryFactoryBean();
|
||||
repositoryFactoryBean.setDataSource(embeddedDatabase);
|
||||
repositoryFactoryBean.setTransactionManager(transactionManager);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2021 the original author or authors.
|
||||
* Copyright 2018-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -52,7 +52,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.core.MessagingTemplate;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.jdbc.support.JdbcTransactionManager;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
@@ -325,8 +325,8 @@ public class RemoteChunkingManagerStepBuilderTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DataSourceTransactionManager transactionManager(DataSource dataSource) {
|
||||
return new DataSourceTransactionManager(dataSource);
|
||||
public JdbcTransactionManager transactionManager(DataSource dataSource) {
|
||||
return new JdbcTransactionManager(dataSource);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
<jdbc:script location="classpath:/org/springframework/batch/core/schema-hsqldb.sql"/>
|
||||
</jdbc:initialize-database>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.support.JdbcTransactionManager">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
</bean>
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
<property name="validationQuery" value="${batch.jdbc.validationQuery}" />
|
||||
</bean>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.support.JdbcTransactionManager">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
</bean>
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
<jdbc:script location="classpath:/org/springframework/batch/core/schema-hsqldb.sql"/>
|
||||
</jdbc:initialize-database>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.support.JdbcTransactionManager">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
</bean>
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
<jdbc:script location="classpath:/org/springframework/batch/core/schema-hsqldb.sql"/>
|
||||
</jdbc:initialize-database>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.support.JdbcTransactionManager">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
</bean>
|
||||
|
||||
|
||||
@@ -52,6 +52,6 @@
|
||||
p:driverClassName="${batch.jdbc.driver}" p:url="${batch.jdbc.url}"
|
||||
p:username="${batch.jdbc.user}" p:password="${batch.jdbc.password}"/>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.support.JdbcTransactionManager"
|
||||
p:dataSource-ref="dataSource"/>
|
||||
</beans>
|
||||
|
||||
@@ -52,6 +52,6 @@
|
||||
p:driverClassName="${batch.jdbc.driver}" p:url="${batch.jdbc.url}"
|
||||
p:username="${batch.jdbc.user}" p:password="${batch.jdbc.password}"/>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.support.JdbcTransactionManager"
|
||||
p:dataSource-ref="dataSource"/>
|
||||
</beans>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<jdbc:script location="classpath:/org/springframework/batch/core/schema-hsqldb.sql"/>
|
||||
</jdbc:initialize-database>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.support.JdbcTransactionManager">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
</bean>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<jdbc:script location="classpath:/org/springframework/batch/core/schema-hsqldb.sql"/>
|
||||
</jdbc:initialize-database>
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||
<bean id="transactionManager" class="org.springframework.jdbc.support.JdbcTransactionManager">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
</bean>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user