diff --git a/jOOQ/src/main/java/org/jooq/Configuration.java b/jOOQ/src/main/java/org/jooq/Configuration.java
index ec11678e77..fccdf32773 100644
--- a/jOOQ/src/main/java/org/jooq/Configuration.java
+++ b/jOOQ/src/main/java/org/jooq/Configuration.java
@@ -305,6 +305,12 @@ public interface Configuration extends Serializable {
*/
DiagnosticsListenerProvider[] diagnosticsListenerProviders();
+ /**
+ * Get the configured UnwrapperProvider from this
+ * configuration.
+ */
+ UnwrapperProvider unwrapperProvider();
+
/**
* Get this configuration's underlying record mapper provider.
*/
@@ -691,7 +697,7 @@ public interface Configuration extends Serializable {
Configuration set(DiagnosticsListener... newDiagnosticsListeners);
/**
- * Change this configuration to hold a new diagnostics listener providers.
+ * Change this configuration to hold new diagnostics listener providers.
*
* This method is not thread-safe and should not be used in globally
* available Configuration objects.
@@ -702,6 +708,30 @@ public interface Configuration extends Serializable {
*/
Configuration set(DiagnosticsListenerProvider... newDiagnosticsListenerProviders);
+ /**
+ * Change this configuration to hold a new unwrapper.
+ *
+ * This method is not thread-safe and should not be used in globally
+ * available Configuration objects.
+ *
+ * @param newUnwrapper The new unwrapper to be contained in the changed
+ * configuration.
+ * @return The changed configuration.
+ */
+ Configuration set(Unwrapper newUnwrapper);
+
+ /**
+ * Change this configuration to hold a new unwrapper provider.
+ *
+ * This method is not thread-safe and should not be used in globally
+ * available Configuration objects.
+ *
+ * @param newUnwrapperProvider The new unwrapper provider to be contained in
+ * the changed configuration.
+ * @return The changed configuration.
+ */
+ Configuration set(UnwrapperProvider newUnwrapperProvider);
+
/**
* Change this configuration to hold a new converter provider.
*
@@ -987,6 +1017,25 @@ public interface Configuration extends Serializable {
*/
Configuration derive(DiagnosticsListenerProvider... newDiagnosticsListenerProviders);
+ /**
+ * Create a derived configuration from this one, with a new unwrapper.
+ *
+ * @param newUnwrapper The new unwrapper to be contained in the derived
+ * configuration.
+ * @return The derived configuration.
+ */
+ Configuration derive(Unwrapper newUnwrapper);
+
+ /**
+ * Create a derived configuration from this one, with a new unwrapper
+ * provider.
+ *
+ * @param newUnwrapperProvider The new unwrapper provider to be contained in
+ * the derived configuration.
+ * @return The derived configuration.
+ */
+ Configuration derive(UnwrapperProvider newUnwrapperProvider);
+
/**
* Create a derived configuration from this one, with new converter
* provider.
diff --git a/jOOQ/src/main/java/org/jooq/Unwrapper.java b/jOOQ/src/main/java/org/jooq/Unwrapper.java
new file mode 100644
index 0000000000..36a046144a
--- /dev/null
+++ b/jOOQ/src/main/java/org/jooq/Unwrapper.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Other licenses:
+ * -----------------------------------------------------------------------------
+ * Commercial licenses for this work are available. These replace the above
+ * ASL 2.0 and offer limited warranties, support, maintenance, and commercial
+ * database integrations.
+ *
+ * For more information, please visit: http://www.jooq.org/licenses
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+package org.jooq;
+
+import java.sql.Connection;
+import java.sql.Wrapper;
+
+/**
+ * An unwrapper SPI that can be used to override the default unwrapping
+ * algorithm.
+ *
+ * In some cases, jOOQ needs to get access to the native JDBC driver APIs in
+ * order to call vendor specific methods, such as Oracle's
+ * OracleConnection.createARRAY(). jOOQ doesn't expect clients to
+ * provide a native JDBC {@link Connection} through the
+ * {@link ConnectionProvider} SPI. Implementations may well provide jOOQ with
+ * some proxy that implements things like logging, thread-bound
+ * transactionality, connection pooling, etc.
+ *
+ * In order to access the native API, {@link Wrapper#unwrap(Class)} needs to be
+ * called, or in some cases, when third party libraries do not properly
+ * implement this contract, some specific methods are called reflectively,
+ * including:
+ *
+ * Not all such third party libraries are "known" to jOOQ, so clients can
+ * implement their own unwrapper to support theirs.
+ *
+ * @author Lukas Eder
+ */
+public interface Unwrapper {
+
+ /**
+ * Unwrap a wrapped type from a JDBC {@link Wrapper}.
+ */
+ T unwrap(Wrapper wrapper, Class iface);
+}
diff --git a/jOOQ/src/main/java/org/jooq/UnwrapperProvider.java b/jOOQ/src/main/java/org/jooq/UnwrapperProvider.java
new file mode 100644
index 0000000000..9754a210be
--- /dev/null
+++ b/jOOQ/src/main/java/org/jooq/UnwrapperProvider.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Other licenses:
+ * -----------------------------------------------------------------------------
+ * Commercial licenses for this work are available. These replace the above
+ * ASL 2.0 and offer limited warranties, support, maintenance, and commercial
+ * database integrations.
+ *
+ * For more information, please visit: http://www.jooq.org/licenses
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+package org.jooq;
+
+import java.sql.Wrapper;
+
+/**
+ * A provider for the {@link Unwrapper} SPI which is used to override the
+ * default behaviour when unwrapping JDBC types through
+ * {@link Wrapper#unwrap(Class)}.
+ *
+ * @author Lukas Eder
+ */
+
+@FunctionalInterface
+
+public interface UnwrapperProvider {
+
+ /**
+ * Provide an unwrapper for JDBC types.
+ */
+ Unwrapper provide();
+}
diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultConfiguration.java b/jOOQ/src/main/java/org/jooq/impl/DefaultConfiguration.java
index 2ec973fcff..91d44277c0 100644
--- a/jOOQ/src/main/java/org/jooq/impl/DefaultConfiguration.java
+++ b/jOOQ/src/main/java/org/jooq/impl/DefaultConfiguration.java
@@ -75,6 +75,8 @@ import org.jooq.SQLDialect;
import org.jooq.TransactionListener;
import org.jooq.TransactionListenerProvider;
import org.jooq.TransactionProvider;
+import org.jooq.Unwrapper;
+import org.jooq.UnwrapperProvider;
import org.jooq.VisitListener;
import org.jooq.VisitListenerProvider;
import org.jooq.conf.Settings;
@@ -91,7 +93,6 @@ import org.jooq.impl.Tools.DataCacheKey;
*
* @author Lukas Eder
*/
-@SuppressWarnings("deprecation")
public class DefaultConfiguration implements Configuration {
/**
@@ -118,6 +119,7 @@ public class DefaultConfiguration implements Configuration {
private transient VisitListenerProvider[] visitListenerProviders;
private transient TransactionListenerProvider[] transactionListenerProviders;
private transient DiagnosticsListenerProvider[] diagnosticsListenerProviders;
+ private transient UnwrapperProvider unwrapperProvider;
private transient ConverterProvider converterProvider;
// [#7062] Apart from the possibility of containing user defined objects, the data
@@ -163,6 +165,11 @@ public class DefaultConfiguration implements Configuration {
null,
null,
null,
+ null,
+ null,
+ null,
+ null,
+ null,
dialect,
SettingsTools.defaultSettings(),
null
@@ -539,7 +546,14 @@ public class DefaultConfiguration implements Configuration {
* configuration properties in the future, without breaking client code.
* Consider creating a configuration by chaining calls to various
* derive() methods.
+ *
+ * @deprecated Use
+ * {@link #DefaultConfiguration(ConnectionProvider, ExecutorProvider, TransactionProvider, RecordMapperProvider, RecordUnmapperProvider, RecordListenerProvider[], ExecuteListenerProvider[], VisitListenerProvider[], TransactionListenerProvider[], DiagnosticsListenerProvider[], UnwrapperProvider, ConverterProvider, SQLDialect, Settings, Map)}
+ * instead. This constructor is maintained to provide jOOQ 3.2,
+ * 3.3, 3.7, 3.8, 3.9, 3.10, 3.11 backwards-compatibility if
+ * called with reflection from Spring configurations.
*/
+ @Deprecated
DefaultConfiguration(
ConnectionProvider connectionProvider,
MetaProvider metaProvider,
@@ -556,6 +570,59 @@ public class DefaultConfiguration implements Configuration {
Clock clock,
+ SQLDialect dialect,
+ Settings settings,
+ Map