Add support for org.jooq.RecordUnmapperProvider

Closes gh-12560
pull/12627/merge
Stephane Nicoll 7 years ago
parent bf4c57209b
commit ccbfcbedf0

@ -23,6 +23,7 @@ import org.jooq.DSLContext;
import org.jooq.ExecuteListenerProvider;
import org.jooq.RecordListenerProvider;
import org.jooq.RecordMapperProvider;
import org.jooq.RecordUnmapperProvider;
import org.jooq.TransactionProvider;
import org.jooq.VisitListenerProvider;
import org.jooq.conf.Settings;
@ -94,6 +95,8 @@ public class JooqAutoConfiguration {
private final RecordMapperProvider recordMapperProvider;
private final RecordUnmapperProvider recordUnmapperProvider;
private final Settings settings;
private final RecordListenerProvider[] recordListenerProviders;
@ -106,6 +109,7 @@ public class JooqAutoConfiguration {
ConnectionProvider connectionProvider, DataSource dataSource,
ObjectProvider<TransactionProvider> transactionProvider,
ObjectProvider<RecordMapperProvider> recordMapperProvider,
ObjectProvider<RecordUnmapperProvider> recordUnmapperProvider,
ObjectProvider<Settings> settings,
ObjectProvider<RecordListenerProvider[]> recordListenerProviders,
ExecuteListenerProvider[] executeListenerProviders,
@ -115,6 +119,7 @@ public class JooqAutoConfiguration {
this.dataSource = dataSource;
this.transactionProvider = transactionProvider.getIfAvailable();
this.recordMapperProvider = recordMapperProvider.getIfAvailable();
this.recordUnmapperProvider = recordUnmapperProvider.getIfAvailable();
this.settings = settings.getIfAvailable();
this.recordListenerProviders = recordListenerProviders.getIfAvailable();
this.executeListenerProviders = executeListenerProviders;
@ -138,6 +143,9 @@ public class JooqAutoConfiguration {
if (this.recordMapperProvider != null) {
configuration.set(this.recordMapperProvider);
}
if (this.recordUnmapperProvider != null) {
configuration.set(this.recordUnmapperProvider);
}
if (this.settings != null) {
configuration.set(this.settings);
}

@ -27,6 +27,8 @@ import org.jooq.RecordListenerProvider;
import org.jooq.RecordMapper;
import org.jooq.RecordMapperProvider;
import org.jooq.RecordType;
import org.jooq.RecordUnmapper;
import org.jooq.RecordUnmapperProvider;
import org.jooq.SQLDialect;
import org.jooq.TransactionalRunnable;
import org.jooq.VisitListener;
@ -134,18 +136,21 @@ public class JooqAutoConfigurationTests {
public void customProvidersArePickedUp() {
this.contextRunner.withUserConfiguration(JooqDataSourceConfiguration.class,
TxManagerConfiguration.class, TestRecordMapperProvider.class,
TestRecordListenerProvider.class, TestExecuteListenerProvider.class,
TestVisitListenerProvider.class).run((context) -> {
DSLContext dsl = context.getBean(DSLContext.class);
assertThat(dsl.configuration().recordMapperProvider().getClass())
.isEqualTo(TestRecordMapperProvider.class);
assertThat(dsl.configuration().recordListenerProviders().length)
.isEqualTo(1);
assertThat(dsl.configuration().executeListenerProviders().length)
.isEqualTo(2);
assertThat(dsl.configuration().visitListenerProviders().length)
.isEqualTo(1);
});
TestRecordUnmapperProvider.class, TestRecordListenerProvider.class,
TestExecuteListenerProvider.class, TestVisitListenerProvider.class
).run((context) -> {
DSLContext dsl = context.getBean(DSLContext.class);
assertThat(dsl.configuration().recordMapperProvider().getClass())
.isEqualTo(TestRecordMapperProvider.class);
assertThat(dsl.configuration().recordUnmapperProvider().getClass())
.isEqualTo(TestRecordUnmapperProvider.class);
assertThat(dsl.configuration().recordListenerProviders().length)
.isEqualTo(1);
assertThat(dsl.configuration().executeListenerProviders().length)
.isEqualTo(2);
assertThat(dsl.configuration().visitListenerProviders().length)
.isEqualTo(1);
});
}
@Test
@ -230,6 +235,16 @@ public class JooqAutoConfigurationTests {
}
protected static class TestRecordUnmapperProvider implements RecordUnmapperProvider {
@Override
public <E, R extends Record> RecordUnmapper<E, R> provide(
Class<? extends E> aClass, RecordType<R> recordType) {
return null;
}
}
protected static class TestRecordListenerProvider implements RecordListenerProvider {
@Override

@ -3733,6 +3733,7 @@ following jOOQ Types:
* `ConnectionProvider`
* `TransactionProvider`
* `RecordMapperProvider`
* `RecordUnmapperProvider`
* `RecordListenerProvider`
* `ExecuteListenerProvider`
* `VisitListenerProvider`

Loading…
Cancel
Save