diff --git a/jOOQ-codegen/src/main/java/org/jooq/codegen/GenerationTool.java b/jOOQ-codegen/src/main/java/org/jooq/codegen/GenerationTool.java
index 1915ba804d..e45438cba5 100644
--- a/jOOQ-codegen/src/main/java/org/jooq/codegen/GenerationTool.java
+++ b/jOOQ-codegen/src/main/java/org/jooq/codegen/GenerationTool.java
@@ -555,6 +555,20 @@ public class GenerationTool {
database.setConfiguredSchemata(schemata);
database.setIncludes(new String[] { defaultString(d.getIncludes()) });
database.setExcludes(new String[] { defaultString(d.getExcludes()) });
+
+ // [#10763] Currently, the javaTimeTypes flag needs to be set before
+ // the forcedTypesForBuiltinDataTypeExtensions flag.
+ if (d.isDateAsTimestamp() != null)
+ database.setDateAsTimestamp(d.isDateAsTimestamp());
+ if (g.getGenerate().isJavaTimeTypes() != null)
+ database.setJavaTimeTypes(g.getGenerate().isJavaTimeTypes());
+ if (d.isUnsignedTypes() != null)
+ database.setSupportsUnsignedTypes(d.isUnsignedTypes());
+ if (d.isIntegerDisplayWidths() != null)
+ database.setIntegerDisplayWidths(d.isIntegerDisplayWidths());
+ if (d.isIgnoreProcedureReturnValues() != null)
+ database.setIgnoreProcedureReturnValues(d.isIgnoreProcedureReturnValues());
+
database.setIncludeExcludeColumns(TRUE.equals(d.isIncludeExcludeColumns()));
database.setIncludeExcludePackageRoutines(TRUE.equals(d.isIncludeExcludePackageRoutines()));
database.setIncludeForeignKeys(!FALSE.equals(d.isIncludeForeignKeys()));
@@ -667,18 +681,6 @@ public class GenerationTool {
log.warn("DEPRECATED", "The configuration property /configuration/generator/database/enumTypes is experimental and deprecated and will be removed in the future.");
if (Boolean.TRUE.equals(d.isDateAsTimestamp()))
log.warn("DEPRECATED", "The configuration property /configuration/generator/database/dateAsTimestamp is deprecated as it is superseded by custom bindings and converters. It will thus be removed in the future.");
-
- if (d.isDateAsTimestamp() != null)
- database.setDateAsTimestamp(d.isDateAsTimestamp());
- if (g.getGenerate().isJavaTimeTypes() != null)
- database.setJavaTimeTypes(g.getGenerate().isJavaTimeTypes());
- if (d.isUnsignedTypes() != null)
- database.setSupportsUnsignedTypes(d.isUnsignedTypes());
- if (d.isIntegerDisplayWidths() != null)
- database.setIntegerDisplayWidths(d.isIntegerDisplayWidths());
- if (d.isIgnoreProcedureReturnValues() != null)
- database.setIgnoreProcedureReturnValues(d.isIgnoreProcedureReturnValues());
-
if (Boolean.TRUE.equals(d.isIgnoreProcedureReturnValues()))
log.warn("DEPRECATED", "The flag is deprecated and used for backwards-compatibility only. It will be removed in the future.");
diff --git a/jOOQ-meta/src/main/java/org/jooq/meta/AbstractDatabase.java b/jOOQ-meta/src/main/java/org/jooq/meta/AbstractDatabase.java
index 9f677a9007..f8bc1d2756 100644
--- a/jOOQ-meta/src/main/java/org/jooq/meta/AbstractDatabase.java
+++ b/jOOQ-meta/src/main/java/org/jooq/meta/AbstractDatabase.java
@@ -205,6 +205,7 @@ public abstract class AbstractDatabase implements Database {
private List configuredCustomTypes = new ArrayList<>();
private List configuredEnumTypes = new ArrayList<>();
private boolean forcedTypesForBuiltinDataTypeExtensions = true;
+ private boolean builtInForcedTypesInitialised = false;
private List configuredForcedTypes;
private Set unusedForcedTypes = new HashSet<>();
private List configuredEmbeddables = new ArrayList<>();
@@ -1486,80 +1487,6 @@ public abstract class AbstractDatabase implements Database {
@Override
public void setForcedTypesForBuiltinDataTypeExtensions(boolean forcedTypesForBuiltinDataTypeExtensions) {
this.forcedTypesForBuiltinDataTypeExtensions = forcedTypesForBuiltinDataTypeExtensions;
-
- if (forcedTypesForBuiltinDataTypeExtensions) {
- try {
- ClassUtils.loadClass("org.jooq.postgres.extensions.types.Hstore");
-
- getConfiguredForcedTypes().add(new ForcedType()
- .withUserType("org.jooq.postgres.extensions.types.Hstore")
- .withBinding("org.jooq.postgres.extensions.bindings.HstoreBinding")
- .withIncludeTypes("hstore")
- .withPriority(Integer.MIN_VALUE)
- );
- getConfiguredForcedTypes().add(new ForcedType()
- .withUserType("org.jooq.postgres.extensions.types.Hstore[]")
- .withBinding("org.jooq.postgres.extensions.bindings.HstoreArrayBinding")
- .withIncludeTypes("_hstore")
- .withPriority(Integer.MIN_VALUE)
- );
-
- getConfiguredForcedTypes().add(new ForcedType()
- .withUserType("org.jooq.postgres.extensions.types.Inet")
- .withBinding("org.jooq.postgres.extensions.bindings.InetBinding")
- .withIncludeTypes("inet")
- .withPriority(Integer.MIN_VALUE)
- );
- getConfiguredForcedTypes().add(new ForcedType()
- .withUserType("org.jooq.postgres.extensions.types.Inet[]")
- .withBinding("org.jooq.postgres.extensions.bindings.InetArrayBinding")
- .withIncludeTypes("_inet")
- .withPriority(Integer.MIN_VALUE)
- );
-
- getConfiguredForcedTypes().add(new ForcedType()
- .withUserType("org.jooq.postgres.extensions.types.Cidr")
- .withBinding("org.jooq.postgres.extensions.bindings.CidrBinding")
- .withIncludeTypes("cidr")
- .withPriority(Integer.MIN_VALUE)
- );
- getConfiguredForcedTypes().add(new ForcedType()
- .withUserType("org.jooq.postgres.extensions.types.Cidr[]")
- .withBinding("org.jooq.postgres.extensions.bindings.CidrArrayBinding")
- .withIncludeTypes("_cidr")
- .withPriority(Integer.MIN_VALUE)
- );
-
- getConfiguredForcedTypes().add(new ForcedType()
- .withUserType("org.jooq.postgres.extensions.types.IntegerRange")
- .withBinding("org.jooq.postgres.extensions.bindings.IntegerRangeBinding")
- .withIncludeTypes("int4range")
- .withPriority(Integer.MIN_VALUE)
- );
- getConfiguredForcedTypes().add(new ForcedType()
- .withUserType("org.jooq.postgres.extensions.types.IntegerRange[]")
- .withBinding("org.jooq.postgres.extensions.bindings.IntegerRangeArrayBinding")
- .withIncludeTypes("_int4range")
- .withPriority(Integer.MIN_VALUE)
- );
-
- getConfiguredForcedTypes().add(new ForcedType()
- .withUserType("org.jooq.postgres.extensions.types.LongRange")
- .withBinding("org.jooq.postgres.extensions.bindings.LongRangeBinding")
- .withIncludeTypes("int8range")
- .withPriority(Integer.MIN_VALUE)
- );
- getConfiguredForcedTypes().add(new ForcedType()
- .withUserType("org.jooq.postgres.extensions.types.LongRange[]")
- .withBinding("org.jooq.postgres.extensions.bindings.LongRangeArrayBinding")
- .withIncludeTypes("_int8range")
- .withPriority(Integer.MIN_VALUE)
- );
- }
- catch (ClassNotFoundException ignore) {
- log.debug("Built in data types", "org.jooq.postgres.extensions.types.Hstore not found on classpath, ignoring built in data type extensions");
- }
- }
}
@Override
@@ -1956,6 +1883,7 @@ public abstract class AbstractDatabase implements Database {
@Override
public final ForcedType getConfiguredForcedType(Definition definition, DataTypeDefinition definedType) {
+ initBuiltinForcedTypes();
// [#5885] Only the first matching is applied to the data type definition.
forcedTypeLoop:
@@ -2001,6 +1929,113 @@ public abstract class AbstractDatabase implements Database {
return null;
}
+ private void initBuiltinForcedTypes() {
+ if (forcedTypesForBuiltinDataTypeExtensions && !builtInForcedTypesInitialised) {
+ builtInForcedTypesInitialised = true;
+
+ try {
+ ClassUtils.loadClass("org.jooq.postgres.extensions.types.Hstore");
+
+ getConfiguredForcedTypes().add(new ForcedType()
+ .withUserType("org.jooq.postgres.extensions.types.Hstore")
+ .withBinding("org.jooq.postgres.extensions.bindings.HstoreBinding")
+ .withIncludeTypes("hstore")
+ .withPriority(Integer.MIN_VALUE)
+ );
+ getConfiguredForcedTypes().add(new ForcedType()
+ .withUserType("org.jooq.postgres.extensions.types.Hstore[]")
+ .withBinding("org.jooq.postgres.extensions.bindings.HstoreArrayBinding")
+ .withIncludeTypes("_hstore")
+ .withPriority(Integer.MIN_VALUE)
+ );
+
+ getConfiguredForcedTypes().add(new ForcedType()
+ .withUserType("org.jooq.postgres.extensions.types.Inet")
+ .withBinding("org.jooq.postgres.extensions.bindings.InetBinding")
+ .withIncludeTypes("inet")
+ .withPriority(Integer.MIN_VALUE)
+ );
+ getConfiguredForcedTypes().add(new ForcedType()
+ .withUserType("org.jooq.postgres.extensions.types.Inet[]")
+ .withBinding("org.jooq.postgres.extensions.bindings.InetArrayBinding")
+ .withIncludeTypes("_inet")
+ .withPriority(Integer.MIN_VALUE)
+ );
+
+ getConfiguredForcedTypes().add(new ForcedType()
+ .withUserType("org.jooq.postgres.extensions.types.Cidr")
+ .withBinding("org.jooq.postgres.extensions.bindings.CidrBinding")
+ .withIncludeTypes("cidr")
+ .withPriority(Integer.MIN_VALUE)
+ );
+ getConfiguredForcedTypes().add(new ForcedType()
+ .withUserType("org.jooq.postgres.extensions.types.Cidr[]")
+ .withBinding("org.jooq.postgres.extensions.bindings.CidrArrayBinding")
+ .withIncludeTypes("_cidr")
+ .withPriority(Integer.MIN_VALUE)
+ );
+
+ getConfiguredForcedTypes().add(new ForcedType()
+ .withUserType("org.jooq.postgres.extensions.types.IntegerRange")
+ .withBinding("org.jooq.postgres.extensions.bindings.IntegerRangeBinding")
+ .withIncludeTypes("int4range")
+ .withPriority(Integer.MIN_VALUE)
+ );
+ getConfiguredForcedTypes().add(new ForcedType()
+ .withUserType("org.jooq.postgres.extensions.types.IntegerRange[]")
+ .withBinding("org.jooq.postgres.extensions.bindings.IntegerRangeArrayBinding")
+ .withIncludeTypes("_int4range")
+ .withPriority(Integer.MIN_VALUE)
+ );
+
+ getConfiguredForcedTypes().add(new ForcedType()
+ .withUserType("org.jooq.postgres.extensions.types.LongRange")
+ .withBinding("org.jooq.postgres.extensions.bindings.LongRangeBinding")
+ .withIncludeTypes("int8range")
+ .withPriority(Integer.MIN_VALUE)
+ );
+ getConfiguredForcedTypes().add(new ForcedType()
+ .withUserType("org.jooq.postgres.extensions.types.LongRange[]")
+ .withBinding("org.jooq.postgres.extensions.bindings.LongRangeArrayBinding")
+ .withIncludeTypes("_int8range")
+ .withPriority(Integer.MIN_VALUE)
+ );
+
+ if (javaTimeTypes()) {
+ getConfiguredForcedTypes().add(new ForcedType()
+ .withUserType("org.jooq.postgres.extensions.types.LocalDateRange")
+ .withBinding("org.jooq.postgres.extensions.bindings.LocalDateRangeBinding")
+ .withIncludeTypes("daterange")
+ .withPriority(Integer.MIN_VALUE)
+ );
+ getConfiguredForcedTypes().add(new ForcedType()
+ .withUserType("org.jooq.postgres.extensions.types.LocalDateRange[]")
+ .withBinding("org.jooq.postgres.extensions.bindings.LocalDateRangeArrayBinding")
+ .withIncludeTypes("_daterange")
+ .withPriority(Integer.MIN_VALUE)
+ );
+ }
+ else {
+ getConfiguredForcedTypes().add(new ForcedType()
+ .withUserType("org.jooq.postgres.extensions.types.DateRange")
+ .withBinding("org.jooq.postgres.extensions.bindings.DateRangeBinding")
+ .withIncludeTypes("daterange")
+ .withPriority(Integer.MIN_VALUE)
+ );
+ getConfiguredForcedTypes().add(new ForcedType()
+ .withUserType("org.jooq.postgres.extensions.types.DateRange[]")
+ .withBinding("org.jooq.postgres.extensions.bindings.DateRangeArrayBinding")
+ .withIncludeTypes("_daterange")
+ .withPriority(Integer.MIN_VALUE)
+ );
+ }
+ }
+ catch (ClassNotFoundException ignore) {
+ log.debug("Built in data types", "org.jooq.postgres.extensions.types.Hstore not found on classpath, ignoring built in data type extensions");
+ }
+ }
+ }
+
private boolean typeMatchesExcludeInclude(DataTypeDefinition type, String exclude, String include) {
if (exclude != null && matches(type, patterns.pattern(exclude)))
return false;
diff --git a/jOOQ-postgres-extensions/src/main/java/org/jooq/postgres/extensions/bindings/DateRangeArrayBinding.java b/jOOQ-postgres-extensions/src/main/java/org/jooq/postgres/extensions/bindings/DateRangeArrayBinding.java
new file mode 100644
index 0000000000..ef105c9a75
--- /dev/null
+++ b/jOOQ-postgres-extensions/src/main/java/org/jooq/postgres/extensions/bindings/DateRangeArrayBinding.java
@@ -0,0 +1,62 @@
+/*
+ * 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.postgres.extensions.bindings;
+
+import org.jooq.Converter;
+import org.jooq.postgres.extensions.converters.DateRangeConverter;
+import org.jooq.postgres.extensions.types.DateRange;
+
+/**
+ * A binding for the PostgreSQL daterange[] data type.
+ *
+ * @author Lukas Eder
+ */
+public class DateRangeArrayBinding extends AbstractPostgresArrayBinding {
+
+ private static final Converter