mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Back off Jooq's TransactionProvider on custom TransactionProvider
Closes gh-32899
This commit is contained in:
parent
2cdd071775
commit
1606f5b88c
@ -71,6 +71,7 @@ public class JooqAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(PlatformTransactionManager.class)
|
||||
@ConditionalOnMissingBean(TransactionProvider.class)
|
||||
public SpringTransactionProvider transactionProvider(PlatformTransactionManager txManager) {
|
||||
return new SpringTransactionProvider(txManager);
|
||||
}
|
||||
|
@ -29,7 +29,9 @@ import org.jooq.RecordListenerProvider;
|
||||
import org.jooq.RecordMapperProvider;
|
||||
import org.jooq.RecordUnmapperProvider;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.TransactionContext;
|
||||
import org.jooq.TransactionListenerProvider;
|
||||
import org.jooq.TransactionProvider;
|
||||
import org.jooq.TransactionalRunnable;
|
||||
import org.jooq.VisitListenerProvider;
|
||||
import org.jooq.impl.DataSourceConnectionProvider;
|
||||
@ -188,6 +190,16 @@ class JooqAutoConfigurationTests {
|
||||
.isEqualTo(SQLDialect.POSTGRES));
|
||||
}
|
||||
|
||||
@Test
|
||||
void transactionProviderBacksOffOnExistingTransactionProvider() {
|
||||
this.contextRunner
|
||||
.withUserConfiguration(JooqDataSourceConfiguration.class, CustomTransactionProviderConfiguration.class)
|
||||
.run((context) -> {
|
||||
TransactionProvider transactionProvider = context.getBean(TransactionProvider.class);
|
||||
assertThat(transactionProvider).isInstanceOf(CustomTransactionProvider.class);
|
||||
});
|
||||
}
|
||||
|
||||
static class AssertFetch implements TransactionalRunnable {
|
||||
|
||||
private final DSLContext dsl;
|
||||
@ -239,6 +251,16 @@ class JooqAutoConfigurationTests {
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class CustomTransactionProviderConfiguration {
|
||||
|
||||
@Bean
|
||||
TransactionProvider transactionProvider() {
|
||||
return new CustomTransactionProvider();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class TxManagerConfiguration {
|
||||
|
||||
@ -259,4 +281,23 @@ class JooqAutoConfigurationTests {
|
||||
|
||||
}
|
||||
|
||||
static class CustomTransactionProvider implements TransactionProvider {
|
||||
|
||||
@Override
|
||||
public void begin(TransactionContext ctx) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit(TransactionContext ctx) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollback(TransactionContext ctx) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user