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:
Mahmoud Ben Hassine
2022-05-15 07:07:31 +02:00
parent 3ef199b92b
commit 565ddcdf96
82 changed files with 167 additions and 166 deletions

View File

@@ -26,7 +26,7 @@ import org.springframework.batch.core.launch.support.SimpleJobLauncher;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.jdbc.support.JdbcTransactionManager;
import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.util.Assert;
@@ -49,11 +49,11 @@ public class DefaultBatchConfigurer implements BatchConfigurer, InitializingBean
/**
* Create a new {@link DefaultBatchConfigurer} with the passed datasource. This
* constructor will configure a default {@link DataSourceTransactionManager}.
* constructor will configure a default {@link JdbcTransactionManager}.
* @param dataSource to use for the job repository and job explorer
*/
public DefaultBatchConfigurer(DataSource dataSource) {
this(dataSource, new DataSourceTransactionManager(dataSource));
this(dataSource, new JdbcTransactionManager(dataSource));
}
/**

View File

@@ -117,8 +117,8 @@ import org.springframework.transaction.PlatformTransactionManager;
* </ul>
*
* The transaction manager provided by this annotation will be of type
* {@link org.springframework.jdbc.datasource.DataSourceTransactionManager} configured
* with the {@link javax.sql.DataSource} provided within the context.
* {@link org.springframework.jdbc.support.JdbcTransactionManager} configured with the
* {@link javax.sql.DataSource} provided within the context.
*
* In order to use a custom transaction manager, a custom {@link BatchConfigurer} should
* be provided. For example: