Merge branch '2.7.x'

Closes gh-33776
pull/33838/head
Moritz Halbritter 2 years ago
commit 2f542f6c91

@ -21,6 +21,7 @@ import javax.sql.DataSource;
import org.jooq.ConnectionProvider;
import org.jooq.DSLContext;
import org.jooq.ExecuteListenerProvider;
import org.jooq.TransactionProvider;
import org.jooq.impl.DataSourceConnectionProvider;
import org.jooq.impl.DefaultConfiguration;
import org.jooq.impl.DefaultDSLContext;
@ -62,6 +63,7 @@ public class JooqAutoConfiguration {
@Bean
@ConditionalOnBean(PlatformTransactionManager.class)
@ConditionalOnMissingBean(TransactionProvider.class)
public SpringTransactionProvider transactionProvider(PlatformTransactionManager txManager) {
return new SpringTransactionProvider(txManager);
}

@ -25,6 +25,8 @@ import org.jooq.DSLContext;
import org.jooq.ExecuteListener;
import org.jooq.ExecuteListenerProvider;
import org.jooq.SQLDialect;
import org.jooq.TransactionContext;
import org.jooq.TransactionProvider;
import org.jooq.TransactionalRunnable;
import org.jooq.impl.DataSourceConnectionProvider;
import org.jooq.impl.DefaultExecuteListenerProvider;
@ -155,6 +157,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;
@ -206,6 +218,16 @@ class JooqAutoConfigurationTests {
}
@Configuration(proxyBeanMethods = false)
static class CustomTransactionProviderConfiguration {
@Bean
TransactionProvider transactionProvider() {
return new CustomTransactionProvider();
}
}
@Configuration(proxyBeanMethods = false)
static class TxManagerConfiguration {
@ -226,4 +248,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…
Cancel
Save