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:
@@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user