Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e4dfd12

Browse files
Use PlatformTransactionManager in JdbcDefaultBatchConfiguration
This change is required to make it possible to use a JPA transaction manager with the default configuration
1 parent 639d64f commit e4dfd12

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

‎spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableJdbcJobRepository.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import org.springframework.batch.support.DatabaseType;
2020
import org.springframework.context.annotation.Configuration;
2121
import org.springframework.jdbc.core.JdbcOperations;
22-
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
22+
import org.springframework.transaction.PlatformTransactionManager;
2323
import org.springframework.transaction.annotation.Isolation;
2424

2525
import java.lang.annotation.Documented;
@@ -39,7 +39,7 @@
3939
* necessary beans for a JDBC-based infrastructure, including a job repository.
4040
* <p>
4141
* The default configuration assumes that a {@link DataSource} bean named "dataSource" and
42-
* a {@link DataSourceTransactionManager} bean named "transactionManager" are available in
42+
* a {@link PlatformTransactionManager} bean named "transactionManager" are available in
4343
* the application context.
4444
*
4545
* @author Mahmoud Ben Hassine
@@ -107,7 +107,7 @@
107107
String dataSourceRef() default "dataSource";
108108

109109
/**
110-
* Set the {@link DataSourceTransactionManager} to use in the job repository.
110+
* Set the {@link PlatformTransactionManager} to use in the job repository.
111111
* @return the bean name of the transaction manager to use. Defaults to
112112
* {@literal transactionManager}
113113
*/

‎spring-batch-core/src/main/java/org/springframework/batch/core/configuration/support/JdbcDefaultBatchConfiguration.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
import org.springframework.core.convert.support.DefaultConversionService;
4444
import org.springframework.jdbc.core.JdbcOperations;
4545
import org.springframework.jdbc.core.JdbcTemplate;
46-
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
4746
import org.springframework.jdbc.support.MetaDataAccessException;
4847
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;
48+
import org.springframework.transaction.PlatformTransactionManager;
4949

5050
import javax.sql.DataSource;
5151
import java.nio.charset.Charset;
@@ -142,20 +142,20 @@ protected DataSource getDataSource() {
142142
}
143143

144144
@Override
145-
protected DataSourceTransactionManager getTransactionManager() {
146-
String errorMessage = " To use the default configuration, a DataSourceTransactionManager bean named 'transactionManager'"
145+
protected PlatformTransactionManager getTransactionManager() {
146+
String errorMessage = " To use the default configuration, a PlatformTransactionManager bean named 'transactionManager'"
147147
+ " should be defined in the application context but none was found. Override getTransactionManager()"
148148
+ " to provide the transaction manager to use for the job repository.";
149-
if (this.applicationContext.getBeansOfType(DataSourceTransactionManager.class).isEmpty()) {
149+
if (this.applicationContext.getBeansOfType(PlatformTransactionManager.class).isEmpty()) {
150150
throw new BatchConfigurationException(
151-
"Unable to find a DataSourceTransactionManager bean in the application context." + errorMessage);
151+
"Unable to find a PlatformTransactionManager bean in the application context." + errorMessage);
152152
}
153153
else {
154154
if (!this.applicationContext.containsBean("transactionManager")) {
155155
throw new BatchConfigurationException(errorMessage);
156156
}
157157
}
158-
return this.applicationContext.getBean("transactionManager", DataSourceTransactionManager.class);
158+
return this.applicationContext.getBean("transactionManager", PlatformTransactionManager.class);
159159
}
160160

161161
/**

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /