[jOOQ/jOOQ#13655] Add XMLSchemaCollectionDefinition,

XMLNamespaceDefinition, and XMLTypeDefinition to jOOQ-meta
This commit is contained in:
Lukas Eder 2022-06-10 15:57:07 +02:00
parent 74208f3398
commit f915b55590
24 changed files with 1016 additions and 303 deletions

View File

@ -591,6 +591,7 @@ public class GenerationTool {
database.setIncludeTables(!FALSE.equals(d.isIncludeTables()));
database.setIncludeEmbeddables(!FALSE.equals(d.isIncludeEmbeddables()));
database.setIncludeTriggerRoutines(TRUE.equals(d.isIncludeTriggerRoutines()));
database.setIncludeXMLSchemaCollections(!FALSE.equals(d.isIncludeXMLSchemaCollections()));
database.setIncludeUDTs(!FALSE.equals(d.isIncludeUDTs()));
database.setIncludeUniqueKeys(!FALSE.equals(d.isIncludeUniqueKeys()));
database.setForceIntegerTypesOnZeroScaleDecimals(!FALSE.equals(d.isForceIntegerTypesOnZeroScaleDecimals()));
@ -603,6 +604,7 @@ public class GenerationTool {
database.setConfiguredEnumTypes(d.getEnumTypes());
database.setConfiguredForcedTypes(d.getForcedTypes());
database.setForcedTypesForBuiltinDataTypeExtensions(d.isForcedTypesForBuiltinDataTypeExtensions());
database.setForcedTypesForXMLSchemaCollections(d.isForcedTypesForXMLSchemaCollections());
database.setConfiguredEmbeddables(d.getEmbeddables());
database.setConfiguredComments(d.getComments());
database.setConfiguredSyntheticObjects(d.getSyntheticObjects());

View File

@ -192,6 +192,7 @@ import org.jooq.meta.TableDefinition;
import org.jooq.meta.TypedElementDefinition;
import org.jooq.meta.UDTDefinition;
import org.jooq.meta.UniqueKeyDefinition;
import org.jooq.meta.XMLTypeDefinition;
import org.jooq.meta.jaxb.ForcedType;
import org.jooq.meta.jaxb.GeneratedAnnotationType;
import org.jooq.meta.jaxb.GeneratedTextBlocks;
@ -9314,7 +9315,8 @@ public class JavaGenerator extends AbstractGenerator {
type.getQualifiedUserType(),
type.getJavaType(),
Object.class.getName(),
udtMode
udtMode,
type.getXMLTypeDefinition()
);
}
@ -9339,10 +9341,19 @@ public class JavaGenerator extends AbstractGenerator {
}
protected String getType(Database db, SchemaDefinition schema, JavaWriter out, String t, int p, int s, Name u, String javaType, String defaultType, Mode udtMode) {
return getType(db, schema, out, t, p, s, u, javaType, defaultType, udtMode, null);
}
protected String getType(Database db, SchemaDefinition schema, JavaWriter out, String t, int p, int s, Name u, String javaType, String defaultType, Mode udtMode, XMLTypeDefinition xmlType) {
String type = defaultType;
// XML types
if (xmlType != null) {
type = getStrategy().getJavaClassName(xmlType);
}
// Custom types
if (javaType != null) {
else if (javaType != null) {
type = javaType;
}

View File

@ -109,7 +109,6 @@ import org.jooq.conf.RenderQuotedNames;
import org.jooq.exception.DataAccessException;
import org.jooq.exception.DetachedException;
import org.jooq.impl.DSL;
import org.jooq.impl.DefaultExecuteListener;
import org.jooq.impl.SQLDataType;
import org.jooq.meta.jaxb.CatalogMappingType;
import org.jooq.meta.jaxb.CommentType;
@ -147,156 +146,160 @@ import org.jooq.tools.jdbc.JDBCUtils;
*/
public abstract class AbstractDatabase implements Database {
private static final JooqLogger log = JooqLogger.getLogger(AbstractDatabase.class);
private static final Set<SQLDialect> NO_SUPPORT_SCHEMATA = SQLDialect.supportedBy(CUBRID, FIREBIRD, SQLITE);
private static final JooqLogger log = JooqLogger.getLogger(AbstractDatabase.class);
private static final Set<SQLDialect> NO_SUPPORT_SCHEMATA = SQLDialect.supportedBy(CUBRID, FIREBIRD, SQLITE);
// -------------------------------------------------------------------------
// Configuration elements
// -------------------------------------------------------------------------
private Properties properties;
private String basedir;
private SQLDialect dialect;
private Connection connection;
private boolean regexMatchesPartialQualification;
private boolean sqlMatchesPartialQualification;
private OnError onError = OnError.FAIL;
private List<Filter> filters;
private String[] excludes;
private String[] includes = { ".*" };
private boolean includeExcludeColumns = false;
private boolean includeExcludePackageRoutines = false;
private boolean includeInvisibleColumns = true;
private boolean includeTables = true;
private boolean includeEmbeddables = true;
private boolean includeRoutines = true;
private boolean includeTriggerRoutines = false;
private boolean includePackages = true;
private boolean includePackageRoutines = true;
private boolean includePackageUDTs = true;
private boolean includePackageConstants = true;
private boolean includeUDTs = true;
private boolean includeDomains = true;
private boolean includeSequences = true;
private boolean includeIndexes = true;
private boolean includeCheckConstraints = true;
private boolean includeSystemTables = false;
private boolean includeSystemIndexes = false;
private boolean includeSystemCheckConstraints = false;
private boolean includeSystemSequences = false;
private boolean includeSystemUDTs = false;
private boolean includePrimaryKeys = true;
private boolean includeUniqueKeys = true;
private boolean includeForeignKeys = true;
private boolean forceIntegerTypesOnZeroScaleDecimals = true;
private String[] recordVersionFields;
private String[] recordTimestampFields;
private String embeddablePrimaryKeys = null;
private String embeddableUniqueKeys = null;
private String embeddableDomains = null;
private boolean readonlyIdentities = false;
private boolean readonlyComputedColumns = true;
private boolean readonlyNonUpdatableColumns = true;
private boolean supportsUnsignedTypes;
private boolean integerDisplayWidths;
private boolean ignoreProcedureReturnValues;
private boolean dateAsTimestamp;
private boolean javaTimeTypes = true;
private List<CatalogMappingType> configuredCatalogs = new ArrayList<>();
private List<SchemaMappingType> configuredSchemata = new ArrayList<>();
private List<CustomType> configuredCustomTypes = new ArrayList<>();
private List<EnumType> configuredEnumTypes = new ArrayList<>();
private boolean forcedTypesForBuiltinDataTypeExtensions = true;
private boolean builtInForcedTypesInitialised = false;
private List<ForcedType> configuredForcedTypes;
private Set<ForcedType> unusedForcedTypes = new HashSet<>();
private List<EmbeddableDefinitionType> configuredEmbeddables = new ArrayList<>();
private Set<EmbeddableDefinitionType> unusedEmbeddables = new HashSet<>();
private List<CommentType> configuredComments = new ArrayList<>();
private Set<CommentType> unusedComments = new HashSet<>();
private List<SyntheticColumnType> configuredSyntheticColumns = new ArrayList<>();
private Set<SyntheticColumnType> unusedSyntheticColumns = new HashSet<>();
private List<SyntheticReadonlyColumnType> configuredSyntheticReadonlyColumns = new ArrayList<>();
private Set<SyntheticReadonlyColumnType> unusedSyntheticReadonlyColumns = new HashSet<>();
private List<SyntheticReadonlyRowidType> configuredSyntheticReadonlyRowids = new ArrayList<>();
private Set<SyntheticReadonlyRowidType> unusedSyntheticReadonlyRowids = new HashSet<>();
private List<SyntheticIdentityType> configuredSyntheticIdentities = new ArrayList<>();
private Set<SyntheticIdentityType> unusedSyntheticIdentities = new HashSet<>();
private List<SyntheticPrimaryKeyType> configuredSyntheticPrimaryKeys = new ArrayList<>();
private Set<SyntheticPrimaryKeyType> unusedSyntheticPrimaryKeys = new HashSet<>();
private List<SyntheticUniqueKeyType> configuredSyntheticUniqueKeys = new ArrayList<>();
private Set<SyntheticUniqueKeyType> unusedSyntheticUniqueKeys = new HashSet<>();
private List<SyntheticForeignKeyType> configuredSyntheticForeignKeys = new ArrayList<>();
private Set<SyntheticForeignKeyType> unusedSyntheticForeignKeys = new HashSet<>();
private List<SyntheticViewType> configuredSyntheticViews = new ArrayList<>();
private Set<SyntheticViewType> unusedSyntheticViews = new HashSet<>();
private List<SyntheticDaoType> configuredSyntheticDaos = new ArrayList<>();
private SchemaVersionProvider schemaVersionProvider;
private CatalogVersionProvider catalogVersionProvider;
private Comparator<Definition> orderProvider;
private boolean includeRelations = true;
private boolean tableValuedFunctions = true;
private int logSlowQueriesAfterSeconds;
private int logSlowResultsAfterSeconds;
private Properties properties;
private String basedir;
private SQLDialect dialect;
private Connection connection;
private boolean regexMatchesPartialQualification;
private boolean sqlMatchesPartialQualification;
private OnError onError = OnError.FAIL;
private List<Filter> filters;
private String[] excludes;
private String[] includes = { ".*" };
private boolean includeExcludeColumns = false;
private boolean includeExcludePackageRoutines = false;
private boolean includeInvisibleColumns = true;
private boolean includeXMLSchemaCollections = true;
private boolean includeTables = true;
private boolean includeEmbeddables = true;
private boolean includeRoutines = true;
private boolean includeTriggerRoutines = false;
private boolean includePackages = true;
private boolean includePackageRoutines = true;
private boolean includePackageUDTs = true;
private boolean includePackageConstants = true;
private boolean includeUDTs = true;
private boolean includeDomains = true;
private boolean includeSequences = true;
private boolean includeIndexes = true;
private boolean includeCheckConstraints = true;
private boolean includeSystemTables = false;
private boolean includeSystemIndexes = false;
private boolean includeSystemCheckConstraints = false;
private boolean includeSystemSequences = false;
private boolean includeSystemUDTs = false;
private boolean includePrimaryKeys = true;
private boolean includeUniqueKeys = true;
private boolean includeForeignKeys = true;
private boolean forceIntegerTypesOnZeroScaleDecimals = true;
private String[] recordVersionFields;
private String[] recordTimestampFields;
private String embeddablePrimaryKeys = null;
private String embeddableUniqueKeys = null;
private String embeddableDomains = null;
private boolean readonlyIdentities = false;
private boolean readonlyComputedColumns = true;
private boolean readonlyNonUpdatableColumns = true;
private boolean supportsUnsignedTypes;
private boolean integerDisplayWidths;
private boolean ignoreProcedureReturnValues;
private boolean dateAsTimestamp;
private boolean javaTimeTypes = true;
private List<CatalogMappingType> configuredCatalogs = new ArrayList<>();
private List<SchemaMappingType> configuredSchemata = new ArrayList<>();
private List<CustomType> configuredCustomTypes = new ArrayList<>();
private List<EnumType> configuredEnumTypes = new ArrayList<>();
private boolean forcedTypesForBuiltinDataTypeExtensions = true;
private boolean forcedTypesForXMLSchemaCollections = true;
private boolean builtInForcedTypesInitialised = false;
private List<ForcedType> configuredForcedTypes;
private Set<ForcedType> unusedForcedTypes = new HashSet<>();
private List<EmbeddableDefinitionType> configuredEmbeddables = new ArrayList<>();
private Set<EmbeddableDefinitionType> unusedEmbeddables = new HashSet<>();
private List<CommentType> configuredComments = new ArrayList<>();
private Set<CommentType> unusedComments = new HashSet<>();
private List<SyntheticColumnType> configuredSyntheticColumns = new ArrayList<>();
private Set<SyntheticColumnType> unusedSyntheticColumns = new HashSet<>();
private List<SyntheticReadonlyColumnType> configuredSyntheticReadonlyColumns = new ArrayList<>();
private Set<SyntheticReadonlyColumnType> unusedSyntheticReadonlyColumns = new HashSet<>();
private List<SyntheticReadonlyRowidType> configuredSyntheticReadonlyRowids = new ArrayList<>();
private Set<SyntheticReadonlyRowidType> unusedSyntheticReadonlyRowids = new HashSet<>();
private List<SyntheticIdentityType> configuredSyntheticIdentities = new ArrayList<>();
private Set<SyntheticIdentityType> unusedSyntheticIdentities = new HashSet<>();
private List<SyntheticPrimaryKeyType> configuredSyntheticPrimaryKeys = new ArrayList<>();
private Set<SyntheticPrimaryKeyType> unusedSyntheticPrimaryKeys = new HashSet<>();
private List<SyntheticUniqueKeyType> configuredSyntheticUniqueKeys = new ArrayList<>();
private Set<SyntheticUniqueKeyType> unusedSyntheticUniqueKeys = new HashSet<>();
private List<SyntheticForeignKeyType> configuredSyntheticForeignKeys = new ArrayList<>();
private Set<SyntheticForeignKeyType> unusedSyntheticForeignKeys = new HashSet<>();
private List<SyntheticViewType> configuredSyntheticViews = new ArrayList<>();
private Set<SyntheticViewType> unusedSyntheticViews = new HashSet<>();
private List<SyntheticDaoType> configuredSyntheticDaos = new ArrayList<>();
private SchemaVersionProvider schemaVersionProvider;
private CatalogVersionProvider catalogVersionProvider;
private Comparator<Definition> orderProvider;
private boolean includeRelations = true;
private boolean tableValuedFunctions = true;
private int logSlowQueriesAfterSeconds;
private int logSlowResultsAfterSeconds;
// -------------------------------------------------------------------------
// Loaded definitions
// -------------------------------------------------------------------------
private Map<Definition, String> sources;
private List<String> inputCatalogs;
private List<String> inputSchemata;
private Map<String, List<String>> inputSchemataPerCatalog;
private List<CatalogDefinition> catalogs;
private List<SchemaDefinition> schemata;
private List<SequenceDefinition> sequences;
private List<IdentityDefinition> identities;
private List<IndexDefinition> indexes;
private List<UniqueKeyDefinition> primaryKeys;
private List<UniqueKeyDefinition> uniqueKeys;
private List<UniqueKeyDefinition> keys;
private List<ForeignKeyDefinition> foreignKeys;
private List<CheckConstraintDefinition> checkConstraints;
private List<TableDefinition> tables;
private List<EmbeddableDefinition> embeddables;
private List<EnumDefinition> enums;
private List<DomainDefinition> domains;
private List<UDTDefinition> udts;
private List<ArrayDefinition> arrays;
private List<RoutineDefinition> routines;
private List<PackageDefinition> packages;
private Relations relations;
private Map<Definition, String> sources;
private List<String> inputCatalogs;
private List<String> inputSchemata;
private Map<String, List<String>> inputSchemataPerCatalog;
private List<CatalogDefinition> catalogs;
private List<SchemaDefinition> schemata;
private List<SequenceDefinition> sequences;
private List<IdentityDefinition> identities;
private List<IndexDefinition> indexes;
private List<UniqueKeyDefinition> primaryKeys;
private List<UniqueKeyDefinition> uniqueKeys;
private List<UniqueKeyDefinition> keys;
private List<ForeignKeyDefinition> foreignKeys;
private List<CheckConstraintDefinition> checkConstraints;
private List<TableDefinition> tables;
private List<EmbeddableDefinition> embeddables;
private List<EnumDefinition> enums;
private List<DomainDefinition> domains;
private List<XMLSchemaCollectionDefinition> xmlSchemaCollections;
private List<UDTDefinition> udts;
private List<ArrayDefinition> arrays;
private List<RoutineDefinition> routines;
private List<PackageDefinition> packages;
private Relations relations;
private transient Map<SchemaDefinition, List<SequenceDefinition>> sequencesBySchema;
private transient Map<SchemaDefinition, List<IdentityDefinition>> identitiesBySchema;
private transient Map<SchemaDefinition, List<IndexDefinition>> indexesBySchema;
private transient Map<TableDefinition, List<IndexDefinition>> indexesByTable;
private transient Map<SchemaDefinition, List<UniqueKeyDefinition>> primaryKeysBySchema;
private transient Map<SchemaDefinition, List<UniqueKeyDefinition>> uniqueKeysBySchema;
private transient Map<SchemaDefinition, List<UniqueKeyDefinition>> keysBySchema;
private transient Map<SchemaDefinition, List<ForeignKeyDefinition>> foreignKeysBySchema;
private transient Map<SchemaDefinition, List<CheckConstraintDefinition>> checkConstraintsBySchema;
private transient Map<SchemaDefinition, List<TableDefinition>> tablesBySchema;
private transient Map<SchemaDefinition, List<EmbeddableDefinition>> embeddablesByDefiningSchema;
private transient Map<TableDefinition, List<EmbeddableDefinition>> embeddablesByDefiningTable;
private transient Map<TableDefinition, List<EmbeddableDefinition>> embeddablesByReferencingTable;
private transient Map<SchemaDefinition, List<EnumDefinition>> enumsBySchema;
private transient Map<SchemaDefinition, List<DomainDefinition>> domainsBySchema;
private transient Map<SchemaDefinition, List<UDTDefinition>> udtsBySchema;
private transient Map<PackageDefinition, List<UDTDefinition>> udtsByPackage;
private transient Map<SchemaDefinition, List<ArrayDefinition>> arraysBySchema;
private transient Map<SchemaDefinition, List<RoutineDefinition>> routinesBySchema;
private transient Map<SchemaDefinition, List<PackageDefinition>> packagesBySchema;
private transient boolean initialised;
private transient Map<SchemaDefinition, List<SequenceDefinition>> sequencesBySchema;
private transient Map<SchemaDefinition, List<IdentityDefinition>> identitiesBySchema;
private transient Map<SchemaDefinition, List<IndexDefinition>> indexesBySchema;
private transient Map<TableDefinition, List<IndexDefinition>> indexesByTable;
private transient Map<SchemaDefinition, List<UniqueKeyDefinition>> primaryKeysBySchema;
private transient Map<SchemaDefinition, List<UniqueKeyDefinition>> uniqueKeysBySchema;
private transient Map<SchemaDefinition, List<UniqueKeyDefinition>> keysBySchema;
private transient Map<SchemaDefinition, List<ForeignKeyDefinition>> foreignKeysBySchema;
private transient Map<SchemaDefinition, List<CheckConstraintDefinition>> checkConstraintsBySchema;
private transient Map<SchemaDefinition, List<TableDefinition>> tablesBySchema;
private transient Map<SchemaDefinition, List<EmbeddableDefinition>> embeddablesByDefiningSchema;
private transient Map<TableDefinition, List<EmbeddableDefinition>> embeddablesByDefiningTable;
private transient Map<TableDefinition, List<EmbeddableDefinition>> embeddablesByReferencingTable;
private transient Map<SchemaDefinition, List<EnumDefinition>> enumsBySchema;
private transient Map<SchemaDefinition, List<DomainDefinition>> domainsBySchema;
private transient Map<SchemaDefinition, List<XMLSchemaCollectionDefinition>> xmlSchemaCollectionsBySchema;
private transient Map<SchemaDefinition, List<UDTDefinition>> udtsBySchema;
private transient Map<PackageDefinition, List<UDTDefinition>> udtsByPackage;
private transient Map<SchemaDefinition, List<ArrayDefinition>> arraysBySchema;
private transient Map<SchemaDefinition, List<RoutineDefinition>> routinesBySchema;
private transient Map<SchemaDefinition, List<PackageDefinition>> packagesBySchema;
private transient boolean initialised;
// Other caches
private final List<Definition> all;
private final List<Definition> included;
private final List<Definition> excluded;
private final Map<Table<?>, Boolean> existTables;
private final Map<TableField<?, ?>, Boolean> existFields;
private final Patterns patterns;
private final Statements statements;
private final List<Definition> all;
private final List<Definition> included;
private final List<Definition> excluded;
private final Map<Table<?>, Boolean> existTables;
private final Map<TableField<?, ?>, Boolean> existFields;
private final Patterns patterns;
private final Statements statements;
protected AbstractDatabase() {
existTables = new HashMap<>();
@ -755,6 +758,43 @@ public abstract class AbstractDatabase implements Database {
return null;
}
@Override
public final List<XMLSchemaCollectionDefinition> getXMLSchemaCollections() {
if (xmlSchemaCollections == null) {
xmlSchemaCollections = new ArrayList<>();
if (getIncludeXMLSchemaCollections()) {
onError(ERROR, "Error while fetching XML schema collections", () -> {
List<XMLSchemaCollectionDefinition> sc = getXMLSchemaCollections0();
xmlSchemaCollections = sort(filterExcludeInclude(sc));
log.info("XML schema collections fetched", fetchedSize(sc, xmlSchemaCollections));
});
}
else
log.info("XML schema collections excluded");
}
return xmlSchemaCollections;
}
@Override
public final List<XMLSchemaCollectionDefinition> getXMLSchemaCollections(SchemaDefinition schema) {
if (xmlSchemaCollectionsBySchema == null)
xmlSchemaCollectionsBySchema = new LinkedHashMap<>();
return filterSchema(getXMLSchemaCollections(), schema, xmlSchemaCollectionsBySchema);
}
@Override
public final XMLSchemaCollectionDefinition getXMLSchemaCollection(SchemaDefinition schema, String inputName) {
for (XMLSchemaCollectionDefinition sc : getXMLSchemaCollections(schema))
if (sc.getName().equals(inputName))
return sc;
return null;
}
@Override
public final List<String> getInputCatalogs() {
if (inputCatalogs == null) {
@ -1095,6 +1135,16 @@ public abstract class AbstractDatabase implements Database {
this.includePackageConstants = includePackageConstants;
}
@Override
public final boolean getIncludeXMLSchemaCollections() {
return includeXMLSchemaCollections;
}
@Override
public final void setIncludeXMLSchemaCollections(boolean includeXMLSchemaCollections) {
this.includeXMLSchemaCollections = includeXMLSchemaCollections;
}
@Override
public final boolean getIncludeUDTs() {
return includeUDTs;
@ -1536,6 +1586,16 @@ public abstract class AbstractDatabase implements Database {
this.forcedTypesForBuiltinDataTypeExtensions = forcedTypesForBuiltinDataTypeExtensions;
}
@Override
public boolean getForcedTypesForXMLSchemaCollections() {
return this.forcedTypesForXMLSchemaCollections;
}
@Override
public void setForcedTypesForXMLSchemaCollections(boolean forcedTypesForXMLSchemaCollections) {
this.forcedTypesForXMLSchemaCollections = forcedTypesForXMLSchemaCollections;
}
@Override
public final int getLogSlowQueriesAfterSeconds() {
return logSlowQueriesAfterSeconds;
@ -1977,186 +2037,188 @@ public abstract class AbstractDatabase implements Database {
}
private void initBuiltinForcedTypes() {
if (forcedTypesForBuiltinDataTypeExtensions && !builtInForcedTypesInitialised) {
if (!builtInForcedTypesInitialised) {
builtInForcedTypesInitialised = true;
try {
ClassUtils.loadClass("org.jooq.postgres.extensions.types.Hstore");
if (forcedTypesForBuiltinDataTypeExtensions) {
try {
ClassUtils.loadClass("org.jooq.postgres.extensions.types.Hstore");
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("java.lang.String")
.withBinding("org.jooq.postgres.extensions.bindings.CitextBinding")
.withIncludeTypes("citext")
.withPriority(Integer.MIN_VALUE)
);
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("java.lang.String[]")
.withBinding("org.jooq.postgres.extensions.bindings.CitextArrayBinding")
.withIncludeTypes("_citext")
.withPriority(Integer.MIN_VALUE)
);
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("org.jooq.postgres.extensions.types.Ltree")
.withBinding("org.jooq.postgres.extensions.bindings.LtreeBinding")
.withIncludeTypes("ltree")
.withPriority(Integer.MIN_VALUE)
);
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("org.jooq.postgres.extensions.types.Ltree[]")
.withBinding("org.jooq.postgres.extensions.bindings.LtreeArrayBinding")
.withIncludeTypes("_ltree")
.withPriority(Integer.MIN_VALUE)
);
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)
);
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("org.jooq.postgres.extensions.types.BigDecimalRange")
.withBinding("org.jooq.postgres.extensions.bindings.BigDecimalRangeBinding")
.withIncludeTypes("numrange")
.withPriority(Integer.MIN_VALUE)
);
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("org.jooq.postgres.extensions.types.BigDecimalRange[]")
.withBinding("org.jooq.postgres.extensions.bindings.BigDecimalRangeArrayBinding")
.withIncludeTypes("_numrange")
.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")
.withUserType("java.lang.String")
.withBinding("org.jooq.postgres.extensions.bindings.CitextBinding")
.withIncludeTypes("citext")
.withPriority(Integer.MIN_VALUE)
);
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("org.jooq.postgres.extensions.types.LocalDateRange[]")
.withBinding("org.jooq.postgres.extensions.bindings.LocalDateRangeArrayBinding")
.withIncludeTypes("_daterange")
.withUserType("java.lang.String[]")
.withBinding("org.jooq.postgres.extensions.bindings.CitextArrayBinding")
.withIncludeTypes("_citext")
.withPriority(Integer.MIN_VALUE)
);
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("org.jooq.postgres.extensions.types.LocalDateTimeRange")
.withBinding("org.jooq.postgres.extensions.bindings.LocalDateTimeRangeBinding")
.withIncludeTypes("tsrange")
.withUserType("org.jooq.postgres.extensions.types.Ltree")
.withBinding("org.jooq.postgres.extensions.bindings.LtreeBinding")
.withIncludeTypes("ltree")
.withPriority(Integer.MIN_VALUE)
);
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("org.jooq.postgres.extensions.types.LocalDateTimeRange[]")
.withBinding("org.jooq.postgres.extensions.bindings.LocalDateTimeRangeArrayBinding")
.withIncludeTypes("_tsrange")
.withUserType("org.jooq.postgres.extensions.types.Ltree[]")
.withBinding("org.jooq.postgres.extensions.bindings.LtreeArrayBinding")
.withIncludeTypes("_ltree")
.withPriority(Integer.MIN_VALUE)
);
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)
);
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("org.jooq.postgres.extensions.types.BigDecimalRange")
.withBinding("org.jooq.postgres.extensions.bindings.BigDecimalRangeBinding")
.withIncludeTypes("numrange")
.withPriority(Integer.MIN_VALUE)
);
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("org.jooq.postgres.extensions.types.BigDecimalRange[]")
.withBinding("org.jooq.postgres.extensions.bindings.BigDecimalRangeArrayBinding")
.withIncludeTypes("_numrange")
.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)
);
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("org.jooq.postgres.extensions.types.LocalDateTimeRange")
.withBinding("org.jooq.postgres.extensions.bindings.LocalDateTimeRangeBinding")
.withIncludeTypes("tsrange")
.withPriority(Integer.MIN_VALUE)
);
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("org.jooq.postgres.extensions.types.LocalDateTimeRange[]")
.withBinding("org.jooq.postgres.extensions.bindings.LocalDateTimeRangeArrayBinding")
.withIncludeTypes("_tsrange")
.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)
);
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("org.jooq.postgres.extensions.types.TimestampRange")
.withBinding("org.jooq.postgres.extensions.bindings.TimestampRangeBinding")
.withIncludeTypes("tsrange")
.withPriority(Integer.MIN_VALUE)
);
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("org.jooq.postgres.extensions.types.TimestampRange[]")
.withBinding("org.jooq.postgres.extensions.bindings.TimestampRangeArrayBinding")
.withIncludeTypes("_tsrange")
.withPriority(Integer.MIN_VALUE)
);
}
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("org.jooq.postgres.extensions.types.OffsetDateTimeRange")
.withBinding("org.jooq.postgres.extensions.bindings.OffsetDateTimeRangeBinding")
.withIncludeTypes("tstzrange")
.withPriority(Integer.MIN_VALUE)
);
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("org.jooq.postgres.extensions.types.OffsetDateTimeRange[]")
.withBinding("org.jooq.postgres.extensions.bindings.OffsetDateTimeRangeArrayBinding")
.withIncludeTypes("_tstzrange")
.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)
);
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("org.jooq.postgres.extensions.types.TimestampRange")
.withBinding("org.jooq.postgres.extensions.bindings.TimestampRangeBinding")
.withIncludeTypes("tsrange")
.withPriority(Integer.MIN_VALUE)
);
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("org.jooq.postgres.extensions.types.TimestampRange[]")
.withBinding("org.jooq.postgres.extensions.bindings.TimestampRangeArrayBinding")
.withIncludeTypes("_tsrange")
.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");
}
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("org.jooq.postgres.extensions.types.OffsetDateTimeRange")
.withBinding("org.jooq.postgres.extensions.bindings.OffsetDateTimeRangeBinding")
.withIncludeTypes("tstzrange")
.withPriority(Integer.MIN_VALUE)
);
getConfiguredForcedTypes().add(new ForcedType()
.withUserType("org.jooq.postgres.extensions.types.OffsetDateTimeRange[]")
.withBinding("org.jooq.postgres.extensions.bindings.OffsetDateTimeRangeArrayBinding")
.withIncludeTypes("_tstzrange")
.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");
}
}
}
@ -3595,6 +3657,12 @@ public abstract class AbstractDatabase implements Database {
*/
protected abstract List<DomainDefinition> getDomains0() throws SQLException;
/**
* Retrieve ALL XML schema collections from the database. This will be
* filtered in {@link #getXMLSchemaCollections()}
*/
protected abstract List<XMLSchemaCollectionDefinition> getXMLSchemaCollections0() throws SQLException;
/**
* Retrieve ALL UDTs from the database. This will be filtered in
* {@link #getEnums(SchemaDefinition)}

View File

@ -245,6 +245,12 @@ public abstract class AbstractMetaDatabase extends AbstractDatabase {
return result;
}
@Override
protected List<XMLSchemaCollectionDefinition> getXMLSchemaCollections0() throws SQLException {
List<XMLSchemaCollectionDefinition> result = new ArrayList<>();
return result;
}
@Override
protected List<UDTDefinition> getUDTs0() throws SQLException {
List<UDTDefinition> result = new ArrayList<>();

View File

@ -143,6 +143,11 @@ public interface DataTypeDefinition {
*/
GenerationOption getGenerationOption();
/**
* The XML type definition, if available.
*/
XMLTypeDefinition getXMLTypeDefinition();
/**
* The computed column generation location.
*/

View File

@ -107,6 +107,21 @@ public interface Database extends AutoCloseable {
*/
SchemaDefinition getSchema(String name);
/**
* The XML schema collections generated from this database.
*/
List<XMLSchemaCollectionDefinition> getXMLSchemaCollections();
/**
* The XML schema collections generated from this database.
*/
List<XMLSchemaCollectionDefinition> getXMLSchemaCollections(SchemaDefinition schema);
/**
* The XML schema collection generated from this database by name
*/
XMLSchemaCollectionDefinition getXMLSchemaCollection(SchemaDefinition schema, String name);
/**
* Retrieve the schema's primary key / foreign key relations.
*/
@ -604,6 +619,16 @@ public interface Database extends AutoCloseable {
*/
boolean getIncludeSequences();
/**
* whether XML schema collections should be included.
*/
boolean getIncludeXMLSchemaCollections();
/**
* whether XML schema collections should be included.
*/
void setIncludeXMLSchemaCollections(boolean includeXMLSchemaCollections);
/**
* whether user defined types should be included.
*/
@ -943,6 +968,26 @@ public interface Database extends AutoCloseable {
*/
void setForcedTypesForBuiltinDataTypeExtensions(boolean forcedTypesForBuiltinDataTypeExtensions);
/**
* Whether some additional forced types for
* {@link XMLSchemaCollectionDefinition} types should be created
* automatically for columns that have non-ambiguous references to an
* {@link XMLTypeDefinition}.
* <p>
* This feature is available in the commercial distribution only.
*/
boolean getForcedTypesForXMLSchemaCollections();
/**
* Whether some additional forced types for
* {@link XMLSchemaCollectionDefinition} types should be created
* automatically for columns that have non-ambiguous references to an
* {@link XMLTypeDefinition}.
* <p>
* This feature is available in the commercial distribution only.
*/
void setForcedTypesForXMLSchemaCollections(boolean forcedTypesForXMLSchemaCollections);
/**
* Log slow queries after this amount of seconds.
*/

View File

@ -79,6 +79,7 @@ public class DefaultDataTypeDefinition implements DataTypeDefinition {
private boolean readonly;
private String generatedAlwaysAs;
private GenerationOption generationOption;
private XMLTypeDefinition xmlTypeDefinition;
private boolean identity;
private final String defaultValue;
private final int length;
@ -294,6 +295,11 @@ public class DefaultDataTypeDefinition implements DataTypeDefinition {
return generationOption;
}
@Override
public XMLTypeDefinition getXMLTypeDefinition() {
return xmlTypeDefinition;
}
@Override
public GenerationLocation getGenerationLocation() {
return generator == null ? GenerationLocation.SERVER : GenerationLocation.CLIENT;
@ -314,6 +320,11 @@ public class DefaultDataTypeDefinition implements DataTypeDefinition {
return this;
}
public final DefaultDataTypeDefinition xmlTypeDefinition(XMLTypeDefinition x) {
this.xmlTypeDefinition = x;
return this;
}
public final DefaultDataTypeDefinition identity(boolean i) {
this.identity = i;
return this;

View File

@ -0,0 +1,69 @@
/*
* 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.meta;
import java.util.ArrayList;
import java.util.List;
/**
* @author Lukas Eder
*/
public class DefaultXMLNamespaceDefinition extends AbstractDefinition implements XMLNamespaceDefinition {
final XMLSchemaCollectionDefinition schemaCollection;
final List<XMLTypeDefinition> types;
public DefaultXMLNamespaceDefinition(XMLSchemaCollectionDefinition schemaCollection, String name) {
super(schemaCollection.getDatabase(), schemaCollection.getSchema(), name);
this.schemaCollection = schemaCollection;
this.types = new ArrayList<>();
schemaCollection.getNamespaces().add(this);
}
@Override
public List<XMLTypeDefinition> getTypes() {
return types;
}
@Override
public XMLSchemaCollectionDefinition getSchemaCollection() {
return schemaCollection;
}
}

View File

@ -0,0 +1,75 @@
/*
* 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.meta;
import static java.util.stream.Collectors.toList;
import java.util.ArrayList;
import java.util.List;
/**
* @author Lukas Eder
*/
public class DefaultXMLSchemaCollectionDefinition extends AbstractDefinition implements XMLSchemaCollectionDefinition {
final List<XMLNamespaceDefinition> namespaces;
List<XMLTypeDefinition> rootElementTypes;
public DefaultXMLSchemaCollectionDefinition(SchemaDefinition schema, String name) {
super(schema.getDatabase(), schema, name);
namespaces = new ArrayList<>();
}
@Override
public List<XMLNamespaceDefinition> getNamespaces() {
return namespaces;
}
@Override
public List<XMLTypeDefinition> getRootElementTypes() {
if (rootElementTypes == null)
rootElementTypes = getNamespaces()
.stream()
.flatMap(n -> n.getTypes().stream())
.filter(t -> t.isRootElementType())
.collect(toList());
return rootElementTypes;
}
}

View File

@ -0,0 +1,71 @@
/*
* 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.meta;
/**
* @author Lukas Eder
*/
public class DefaultXMLTypeDefinition extends AbstractDefinition implements XMLTypeDefinition {
final XMLNamespaceDefinition namespace;
final int rootElementCount;
public DefaultXMLTypeDefinition(XMLNamespaceDefinition namespace, String name, int rootElementCount) {
super(namespace.getDatabase(), namespace.getSchema(), name);
this.namespace = namespace;
this.rootElementCount = rootElementCount;
namespace.getTypes().add(this);
}
@Override
public XMLNamespaceDefinition getNamespace() {
return namespace;
}
@Override
public boolean isRootElementType() {
return rootElementCount > 0;
}
@Override
public int getRootElementCount() {
return rootElementCount;
}
}

View File

@ -0,0 +1,63 @@
/*
* 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.meta;
import java.util.List;
import org.jetbrains.annotations.NotNull;
/**
* A definition representing an XML namespace.
*
* @author Lukas Eder
*/
public interface XMLNamespaceDefinition extends Definition {
/**
* The {@link XMLSchemaCollectionDefinition} that contains this namespace
* definition.
*/
@NotNull
XMLSchemaCollectionDefinition getSchemaCollection();
/**
* Get the {@link XMLTypeDefinition} instances belonging to this namespace.
*/
@NotNull
List<XMLTypeDefinition> getTypes();
}

View File

@ -0,0 +1,64 @@
/*
* 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.meta;
import java.util.List;
import org.jetbrains.annotations.NotNull;
/**
* A definition representing an <code>SCHEMA COLLECTION</code>, i.e. a
* collection of XSDs stored in the database.
*
* @author Lukas Eder
*/
public interface XMLSchemaCollectionDefinition extends Definition {
/**
* Get the {@link XMLNamespaceDefinition} instances belonging to this schema
* collection.
*/
@NotNull
List<XMLNamespaceDefinition> getNamespaces();
/**
* Get a list of types that have been declared as potential root elements in
* the XSDs.
*/
List<XMLTypeDefinition> getRootElementTypes();
}

View File

@ -0,0 +1,64 @@
/*
* 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.meta;
import org.jetbrains.annotations.NotNull;
/**
* A definition representing an XML namespace.
*
* @author Lukas Eder
*/
public interface XMLTypeDefinition extends Definition {
/**
* Get the namespace to which this type belongs.
*/
@NotNull
XMLNamespaceDefinition getNamespace();
/**
* Whether this type can be used as a root element.
*/
boolean isRootElementType();
/**
* Get the number of root elements this type is available from.
*/
int getRootElementCount();
}

View File

@ -79,6 +79,7 @@ import org.jooq.meta.SchemaDefinition;
import org.jooq.meta.SequenceDefinition;
import org.jooq.meta.TableDefinition;
import org.jooq.meta.UDTDefinition;
import org.jooq.meta.XMLSchemaCollectionDefinition;
/**
* @author Lukas Eder
@ -266,6 +267,12 @@ public class CUBRIDDatabase extends AbstractDatabase {
return result;
}
@Override
protected List<XMLSchemaCollectionDefinition> getXMLSchemaCollections0() throws SQLException {
List<XMLSchemaCollectionDefinition> result = new ArrayList<>();
return result;
}
@Override
protected List<UDTDefinition> getUDTs0() throws SQLException {
List<UDTDefinition> result = new ArrayList<>();

View File

@ -105,6 +105,7 @@ import org.jooq.meta.SchemaDefinition;
import org.jooq.meta.SequenceDefinition;
import org.jooq.meta.TableDefinition;
import org.jooq.meta.UDTDefinition;
import org.jooq.meta.XMLSchemaCollectionDefinition;
/**
* @author Lukas Eder
@ -458,6 +459,12 @@ public class DerbyDatabase extends AbstractDatabase implements ResultQueryDataba
return result;
}
@Override
protected List<XMLSchemaCollectionDefinition> getXMLSchemaCollections0() throws SQLException {
List<XMLSchemaCollectionDefinition> result = new ArrayList<>();
return result;
}
@Override
protected List<UDTDefinition> getUDTs0() throws SQLException {
List<UDTDefinition> result = new ArrayList<>();

View File

@ -119,6 +119,7 @@ import org.jooq.meta.SchemaDefinition;
import org.jooq.meta.SequenceDefinition;
import org.jooq.meta.TableDefinition;
import org.jooq.meta.UDTDefinition;
import org.jooq.meta.XMLSchemaCollectionDefinition;
import org.jooq.meta.firebird.rdb.tables.Rdb$checkConstraints;
import org.jooq.meta.firebird.rdb.tables.Rdb$fields;
import org.jooq.meta.firebird.rdb.tables.Rdb$functionArguments;
@ -596,6 +597,12 @@ public class FirebirdDatabase extends AbstractDatabase implements ResultQueryDat
return result;
}
@Override
protected List<XMLSchemaCollectionDefinition> getXMLSchemaCollections0() throws SQLException {
List<XMLSchemaCollectionDefinition> result = new ArrayList<>();
return result;
}
@Override
protected List<UDTDefinition> getUDTs0() throws SQLException {
List<UDTDefinition> result = new ArrayList<>();

View File

@ -130,6 +130,7 @@ import org.jooq.meta.SchemaDefinition;
import org.jooq.meta.SequenceDefinition;
import org.jooq.meta.TableDefinition;
import org.jooq.meta.UDTDefinition;
import org.jooq.meta.XMLSchemaCollectionDefinition;
import org.jooq.meta.hsqldb.information_schema.Tables;
import org.jooq.meta.hsqldb.information_schema.tables.CheckConstraints;
import org.jooq.meta.hsqldb.information_schema.tables.DomainConstraints;
@ -1104,6 +1105,12 @@ public class H2Database extends AbstractDatabase implements ResultQueryDatabase
return result;
}
@Override
protected List<XMLSchemaCollectionDefinition> getXMLSchemaCollections0() throws SQLException {
List<XMLSchemaCollectionDefinition> result = new ArrayList<>();
return result;
}
@Override
protected List<UDTDefinition> getUDTs0() throws SQLException {
List<UDTDefinition> result = new ArrayList<>();

View File

@ -107,6 +107,7 @@ import org.jooq.meta.SchemaDefinition;
import org.jooq.meta.SequenceDefinition;
import org.jooq.meta.TableDefinition;
import org.jooq.meta.UDTDefinition;
import org.jooq.meta.XMLSchemaCollectionDefinition;
import org.jooq.meta.hsqldb.information_schema.tables.CheckConstraints;
import org.jooq.meta.hsqldb.information_schema.tables.Columns;
import org.jooq.meta.hsqldb.information_schema.tables.DomainConstraints;
@ -542,6 +543,12 @@ public class HSQLDBDatabase extends AbstractDatabase implements ResultQueryDatab
return result;
}
@Override
protected List<XMLSchemaCollectionDefinition> getXMLSchemaCollections0() throws SQLException {
List<XMLSchemaCollectionDefinition> result = new ArrayList<>();
return result;
}
@Override
protected List<UDTDefinition> getUDTs0() throws SQLException {
List<UDTDefinition> result = new ArrayList<>();

View File

@ -70,6 +70,8 @@ public class Database implements Serializable, XMLAppendable
@XmlElement(defaultValue = "true")
protected Boolean includePackageConstants = true;
@XmlElement(defaultValue = "true")
protected Boolean includeXMLSchemaCollections = true;
@XmlElement(defaultValue = "true")
protected Boolean includeUDTs = true;
@XmlElement(defaultValue = "true")
protected Boolean includeDomains = true;
@ -159,6 +161,8 @@ public class Database implements Serializable, XMLAppendable
@XmlElement(defaultValue = "true")
protected Boolean forcedTypesForBuiltinDataTypeExtensions = true;
@XmlElement(defaultValue = "true")
protected Boolean forcedTypesForXMLSchemaCollections = true;
@XmlElement(defaultValue = "true")
protected Boolean forceIntegerTypesOnZeroScaleDecimals = true;
protected Boolean tableValuedFunctions;
@XmlElement(defaultValue = "5")
@ -667,6 +671,30 @@ public class Database implements Serializable, XMLAppendable
this.includePackageConstants = value;
}
/**
* This flag indicates whether XML schema collections should be included in output produced by this database
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isIncludeXMLSchemaCollections() {
return includeXMLSchemaCollections;
}
/**
* Sets the value of the includeXMLSchemaCollections property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setIncludeXMLSchemaCollections(Boolean value) {
this.includeXMLSchemaCollections = value;
}
/**
* This flag indicates whether udts should be included in output produced by this database
*
@ -1683,6 +1711,32 @@ public class Database implements Serializable, XMLAppendable
this.forcedTypesForBuiltinDataTypeExtensions = value;
}
/**
* Enable some default forced type configurations for XML schema collections, mapping them to JAXB annotated types using the {@link org.jooq.impl.XMLtoJAXBConverter}
* <p>
* This feature is available in the commercial distribution only.
*
* @return
* possible object is
* {@link Boolean }
*
*/
public Boolean isForcedTypesForXMLSchemaCollections() {
return forcedTypesForXMLSchemaCollections;
}
/**
* Sets the value of the forcedTypesForXMLSchemaCollections property.
*
* @param value
* allowed object is
* {@link Boolean }
*
*/
public void setForcedTypesForXMLSchemaCollections(Boolean value) {
this.forcedTypesForXMLSchemaCollections = value;
}
/**
* Historically, zero-scale decimal types are generated as their most appropriate, corresponding integer type (e.g. NUMBER(2, 0) and less: Byte). This allows for turning off this feature. In case of conflict between this rule and actual {@link #getForcedTypes()}, the latter will win.
*
@ -2069,6 +2123,11 @@ public class Database implements Serializable, XMLAppendable
return this;
}
public Database withIncludeXMLSchemaCollections(Boolean value) {
setIncludeXMLSchemaCollections(value);
return this;
}
public Database withIncludeUDTs(Boolean value) {
setIncludeUDTs(value);
return this;
@ -2416,6 +2475,11 @@ public class Database implements Serializable, XMLAppendable
return this;
}
public Database withForcedTypesForXMLSchemaCollections(Boolean value) {
setForcedTypesForXMLSchemaCollections(value);
return this;
}
public Database withForceIntegerTypesOnZeroScaleDecimals(Boolean value) {
setForceIntegerTypesOnZeroScaleDecimals(value);
return this;
@ -2636,6 +2700,7 @@ public class Database implements Serializable, XMLAppendable
builder.append("includePackageRoutines", includePackageRoutines);
builder.append("includePackageUDTs", includePackageUDTs);
builder.append("includePackageConstants", includePackageConstants);
builder.append("includeXMLSchemaCollections", includeXMLSchemaCollections);
builder.append("includeUDTs", includeUDTs);
builder.append("includeDomains", includeDomains);
builder.append("includeSequences", includeSequences);
@ -2676,6 +2741,7 @@ public class Database implements Serializable, XMLAppendable
builder.append("readonlyComputedColumns", readonlyComputedColumns);
builder.append("readonlyNonUpdatableColumns", readonlyNonUpdatableColumns);
builder.append("forcedTypesForBuiltinDataTypeExtensions", forcedTypesForBuiltinDataTypeExtensions);
builder.append("forcedTypesForXMLSchemaCollections", forcedTypesForXMLSchemaCollections);
builder.append("forceIntegerTypesOnZeroScaleDecimals", forceIntegerTypesOnZeroScaleDecimals);
builder.append("tableValuedFunctions", tableValuedFunctions);
builder.append("logSlowQueriesAfterSeconds", logSlowQueriesAfterSeconds);
@ -2853,6 +2919,15 @@ public class Database implements Serializable, XMLAppendable
return false;
}
}
if (includeXMLSchemaCollections == null) {
if (other.includeXMLSchemaCollections!= null) {
return false;
}
} else {
if (!includeXMLSchemaCollections.equals(other.includeXMLSchemaCollections)) {
return false;
}
}
if (includeUDTs == null) {
if (other.includeUDTs!= null) {
return false;
@ -3213,6 +3288,15 @@ public class Database implements Serializable, XMLAppendable
return false;
}
}
if (forcedTypesForXMLSchemaCollections == null) {
if (other.forcedTypesForXMLSchemaCollections!= null) {
return false;
}
} else {
if (!forcedTypesForXMLSchemaCollections.equals(other.forcedTypesForXMLSchemaCollections)) {
return false;
}
}
if (forceIntegerTypesOnZeroScaleDecimals == null) {
if (other.forceIntegerTypesOnZeroScaleDecimals!= null) {
return false;
@ -3344,6 +3428,7 @@ public class Database implements Serializable, XMLAppendable
result = ((prime*result)+((includePackageRoutines == null)? 0 :includePackageRoutines.hashCode()));
result = ((prime*result)+((includePackageUDTs == null)? 0 :includePackageUDTs.hashCode()));
result = ((prime*result)+((includePackageConstants == null)? 0 :includePackageConstants.hashCode()));
result = ((prime*result)+((includeXMLSchemaCollections == null)? 0 :includeXMLSchemaCollections.hashCode()));
result = ((prime*result)+((includeUDTs == null)? 0 :includeUDTs.hashCode()));
result = ((prime*result)+((includeDomains == null)? 0 :includeDomains.hashCode()));
result = ((prime*result)+((includeSequences == null)? 0 :includeSequences.hashCode()));
@ -3384,6 +3469,7 @@ public class Database implements Serializable, XMLAppendable
result = ((prime*result)+((readonlyComputedColumns == null)? 0 :readonlyComputedColumns.hashCode()));
result = ((prime*result)+((readonlyNonUpdatableColumns == null)? 0 :readonlyNonUpdatableColumns.hashCode()));
result = ((prime*result)+((forcedTypesForBuiltinDataTypeExtensions == null)? 0 :forcedTypesForBuiltinDataTypeExtensions.hashCode()));
result = ((prime*result)+((forcedTypesForXMLSchemaCollections == null)? 0 :forcedTypesForXMLSchemaCollections.hashCode()));
result = ((prime*result)+((forceIntegerTypesOnZeroScaleDecimals == null)? 0 :forceIntegerTypesOnZeroScaleDecimals.hashCode()));
result = ((prime*result)+((tableValuedFunctions == null)? 0 :tableValuedFunctions.hashCode()));
result = ((prime*result)+((logSlowQueriesAfterSeconds == null)? 0 :logSlowQueriesAfterSeconds.hashCode()));

View File

@ -106,6 +106,7 @@ import org.jooq.meta.SchemaDefinition;
import org.jooq.meta.SequenceDefinition;
import org.jooq.meta.TableDefinition;
import org.jooq.meta.UDTDefinition;
import org.jooq.meta.XMLSchemaCollectionDefinition;
import org.jooq.meta.mariadb.MariaDBDatabase;
import org.jooq.meta.mysql.mysql.enums.ProcType;
import org.jooq.tools.csv.CSVReader;
@ -523,6 +524,12 @@ public class MySQLDatabase extends AbstractDatabase implements ResultQueryDataba
return result;
}
@Override
protected List<XMLSchemaCollectionDefinition> getXMLSchemaCollections0() throws SQLException {
List<XMLSchemaCollectionDefinition> result = new ArrayList<>();
return result;
}
@Override
protected List<UDTDefinition> getUDTs0() throws SQLException {
List<UDTDefinition> result = new ArrayList<>();

View File

@ -160,6 +160,7 @@ import org.jooq.meta.SchemaDefinition;
import org.jooq.meta.SequenceDefinition;
import org.jooq.meta.TableDefinition;
import org.jooq.meta.UDTDefinition;
import org.jooq.meta.XMLSchemaCollectionDefinition;
import org.jooq.meta.hsqldb.HSQLDBDatabase;
import org.jooq.meta.jaxb.ForcedType;
import org.jooq.meta.postgres.information_schema.tables.CheckConstraints;
@ -891,6 +892,12 @@ public class PostgresDatabase extends AbstractDatabase implements ResultQueryDat
return result;
}
@Override
protected List<XMLSchemaCollectionDefinition> getXMLSchemaCollections0() throws SQLException {
List<XMLSchemaCollectionDefinition> result = new ArrayList<>();
return result;
}
@Override
protected List<UDTDefinition> getUDTs0() throws SQLException {
List<UDTDefinition> result = new ArrayList<>();

View File

@ -103,6 +103,7 @@ import org.jooq.meta.SchemaDefinition;
import org.jooq.meta.SequenceDefinition;
import org.jooq.meta.TableDefinition;
import org.jooq.meta.UDTDefinition;
import org.jooq.meta.XMLSchemaCollectionDefinition;
import org.jooq.meta.jaxb.SchemaMappingType;
import org.jooq.meta.sqlite.sqlite_master.SQLiteMaster;
import org.jooq.tools.JooqLogger;
@ -443,6 +444,12 @@ public class SQLiteDatabase extends AbstractDatabase {
return result;
}
@Override
protected List<XMLSchemaCollectionDefinition> getXMLSchemaCollections0() throws SQLException {
List<XMLSchemaCollectionDefinition> result = new ArrayList<>();
return result;
}
@Override
protected List<UDTDefinition> getUDTs0() throws SQLException {
List<UDTDefinition> result = new ArrayList<>();

View File

@ -104,6 +104,7 @@ import org.jooq.meta.SchemaDefinition;
import org.jooq.meta.SequenceDefinition;
import org.jooq.meta.TableDefinition;
import org.jooq.meta.UDTDefinition;
import org.jooq.meta.XMLSchemaCollectionDefinition;
import org.jooq.tools.JooqLogger;
import org.jooq.tools.StringUtils;
import org.jooq.tools.jdbc.JDBCUtils;
@ -583,6 +584,12 @@ public class XMLDatabase extends AbstractDatabase {
return result;
}
@Override
protected List<XMLSchemaCollectionDefinition> getXMLSchemaCollections0() throws SQLException {
List<XMLSchemaCollectionDefinition> result = new ArrayList<>();
return result;
}
@Override
protected List<UDTDefinition> getUDTs0() {
List<UDTDefinition> result = new ArrayList<>();

View File

@ -634,6 +634,10 @@ Excludes match before includes, i.e. excludes have a higher priority.]]></jxb:ja
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[This flag indicates whether constants contained in packages should be included in output produced by this database]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="includeXMLSchemaCollections" type="boolean" default="true" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[This flag indicates whether XML schema collections should be included in output produced by this database]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="includeUDTs" type="boolean" default="true" minOccurs="0" maxOccurs="1">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[This flag indicates whether udts should be included in output produced by this database]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
@ -955,7 +959,13 @@ This feature is available in the commercial distribution only.]]></jxb:javadoc><
<element name="forcedTypesForBuiltinDataTypeExtensions" type="boolean" minOccurs="0" maxOccurs="1" default="true">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Enable some default forced type configurations for built in data type extensions, such as the ones from the jooq-postgres-extensions module.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="forcedTypesForXMLSchemaCollections" type="boolean" minOccurs="0" maxOccurs="1" default="true">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Enable some default forced type configurations for XML schema collections, mapping them to JAXB annotated types using the {@link org.jooq.impl.XMLtoJAXBConverter}
<p>
This feature is available in the commercial distribution only.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>
<element name="forceIntegerTypesOnZeroScaleDecimals" type="boolean" minOccurs="0" maxOccurs="1" default="true">
<annotation><appinfo><jxb:property><jxb:javadoc><![CDATA[Historically, zero-scale decimal types are generated as their most appropriate, corresponding integer type (e.g. NUMBER(2, 0) and less: Byte). This allows for turning off this feature. In case of conflict between this rule and actual {@link #getForcedTypes()}, the latter will win.]]></jxb:javadoc></jxb:property></appinfo></annotation>
</element>