Available in versions: Dev (3.21) | Latest (3.20) | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11
Catalog and schema mapping
Supported by ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
In addition to what we've seen in the section about input catalogs and schemas, these configuration elements combine two features in one:
- They allow for specifying one or more catalogs (default: all catalogs) as well as one or more schemas (default: all schemas) for inclusion in the code generator. This works in a similar fashion as the includes and excludes elements, but it is applied at an earlier stage of reading the schema meta data.
- Once all "input" catalogs and schemas are specified, they can each be associated with a matching "output" catalog or schema, in case of which the "input" will be mapped to the "output" by the code generator.
Wherever you can place an inputCatalog
or inputSchema
element (top level or nested, see the manual section about input schemas), you can also put a matching mapping instruction, if you wish to profit from the catalog and schema mapping feature. The following configurations are possible:
Top level configurations
This mode is preferrable for small projects or quick tutorials, where only a single catalog and a/or a single schema need to be generated. In this case, the following "top level" configuration elements can be applied:
Read only a single schema (from all catalogs, but in most databases, there is only one "default catalog")
<configuration> <generator> <database> <inputSchema>input_schema</inputSchema> <outputSchema>output_schema</outputSchema> </database> </generator> </configuration>
See the configuration XSD, standalone code generation, and maven code generation for more details.
new org.jooq.meta.jaxb.Configuration() .withGenerator(new Generator() .withDatabase(new Database() .withInputSchema("input_schema") .withOutputSchema("output_schema") ) )
See the configuration XSD and programmatic code generation for more details.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
generationTool { generator { database { inputSchema = "input_schema" outputSchema = "output_schema" } } }
See the configuration XSD and gradle code generation for more details.
Read only a single catalog and all its schemas
<configuration> <generator> <database> <inputCatalog>input_catalog</inputCatalog> <outputCatalog>output_catalog</outputCatalog> </database> </generator> </configuration>
See the configuration XSD, standalone code generation, and maven code generation for more details.
new org.jooq.meta.jaxb.Configuration() .withGenerator(new Generator() .withDatabase(new Database() .withInputCatalog("input_catalog") .withOutputCatalog("output_catalog") ) )
See the configuration XSD and programmatic code generation for more details.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
generationTool { generator { database { inputCatalog = "input_catalog" outputCatalog = "output_catalog" } } }
See the configuration XSD and gradle code generation for more details.
Read only a single catalog and only a single schema
<configuration> <generator> <database> <inputCatalog>input_catalog</inputCatalog> <outputCatalog>output_catalog</outputCatalog> <inputSchema>input_schema</inputSchema> <outputSchema>output_schema</outputSchema> </database> </generator> </configuration>
See the configuration XSD, standalone code generation, and maven code generation for more details.
new org.jooq.meta.jaxb.Configuration() .withGenerator(new Generator() .withDatabase(new Database() .withInputCatalog("input_catalog") .withOutputCatalog("output_catalog") .withInputSchema("input_schema") .withOutputSchema("output_schema") ) )
See the configuration XSD and programmatic code generation for more details.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
generationTool { generator { database { inputCatalog = "input_catalog" outputCatalog = "output_catalog" inputSchema = "input_schema" outputSchema = "output_schema" } } }
See the configuration XSD and gradle code generation for more details.
Nested configurations
This mode is preferrable for larger projects where several catalogs and/or schemas need to be included. The following examples show different possible configurations:
Read two or more schemas (from all catalogs, but in most databases, there is only one "default catalog")
<configuration> <generator> <database> <schemata> <schema> <inputSchema>input_schema1</inputSchema> <outputSchema>output_schema1</outputSchema> </schema> <schema> <inputSchema>input_schema2</inputSchema> <outputSchema>output_schema2</outputSchema> </schema> </schemata> </database> </generator> </configuration>
See the configuration XSD, standalone code generation, and maven code generation for more details.
new org.jooq.meta.jaxb.Configuration() .withGenerator(new Generator() .withDatabase(new Database() .withSchemata( new SchemaMappingType() .withInputSchema("input_schema1") .withOutputSchema("output_schema1"), new SchemaMappingType() .withInputSchema("input_schema2") .withOutputSchema("output_schema2") ) ) )
See the configuration XSD and programmatic code generation for more details.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
generationTool { generator { database { schemata { schema { inputSchema = "input_schema1" outputSchema = "output_schema1" } schema { inputSchema = "input_schema2" outputSchema = "output_schema2" } } } } }
See the configuration XSD and gradle code generation for more details.
Read two or more catalogs and all their schemas
<configuration> <generator> <database> <catalogs> <catalog> <inputCatalog>input_catalog1</inputCatalog> <outputCatalog>output_catalog1</outputCatalog> </catalog> <catalog> <inputCatalog>input_catalog2</inputCatalog> <outputCatalog>output_catalog2</outputCatalog> </catalog> </catalogs> </database> </generator> </configuration>
See the configuration XSD, standalone code generation, and maven code generation for more details.
new org.jooq.meta.jaxb.Configuration() .withGenerator(new Generator() .withDatabase(new Database() .withCatalogs( new CatalogMappingType() .withInputCatalog("input_catalog1") .withOutputCatalog("output_catalog1"), new CatalogMappingType() .withInputCatalog("input_catalog2") .withOutputCatalog("output_catalog2") ) ) )
See the configuration XSD and programmatic code generation for more details.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
generationTool { generator { database { catalogs { catalog { inputCatalog = "input_catalog1" outputCatalog = "output_catalog1" } catalog { inputCatalog = "input_catalog2" outputCatalog = "output_catalog2" } } } } }
See the configuration XSD and gradle code generation for more details.
Read two or more schemas from one or more specific catalogs
<configuration> <generator> <database> <catalogs> <catalog> <inputCatalog>input_catalog</inputCatalog> <outputCatalog>output_catalog</outputCatalog> <schemata> <schema> <inputSchema>input_schema1</inputSchema> <outputSchema>output_schema1</outputSchema> </schema> <schema> <inputSchema>input_schema2</inputSchema> <outputSchema>output_schema2</outputSchema> </schema> </schemata> </catalog> </catalogs> </database> </generator> </configuration>
See the configuration XSD, standalone code generation, and maven code generation for more details.
new org.jooq.meta.jaxb.Configuration() .withGenerator(new Generator() .withDatabase(new Database() .withCatalogs( new CatalogMappingType() .withInputCatalog("input_catalog") .withOutputCatalog("output_catalog") .withSchemata( new SchemaMappingType() .withInputSchema("input_schema1") .withOutputSchema("output_schema1"), new SchemaMappingType() .withInputSchema("input_schema2") .withOutputSchema("output_schema2") ) ) ) )
See the configuration XSD and programmatic code generation for more details.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
generationTool { generator { database { catalogs { catalog { inputCatalog = "input_catalog" outputCatalog = "output_catalog" schemata { schema { inputSchema = "input_schema1" outputSchema = "output_schema1" } schema { inputSchema = "input_schema2" outputSchema = "output_schema2" } } } } } } }
See the configuration XSD and gradle code generation for more details.
Default catalogs and schemas
Instead of specifying an outputCatalog
or outputSchema
, it is also possible to specify outputCatalogToDefault
or outputSchemaToDefault
in order to omit the qualifier entirely from generated code. This is possible both at the top level or in nested configurations:
Top level
<configuration> <generator> <database> <inputCatalog>my_input_catalog</inputCatalog> <outputCatalogToDefault>true</outputCatalogToDefault> <inputSchema>my_input_schema</inputSchema> <outputSchemaToDefault>true</outputSchemaToDefault> </database> </generator> </configuration>
See the configuration XSD, standalone code generation, and maven code generation for more details.
new org.jooq.meta.jaxb.Configuration() .withGenerator(new Generator() .withDatabase(new Database() .withInputCatalog("my_input_catalog") .withOutputCatalogToDefault(true) .withInputSchema("my_input_schema") .withOutputSchemaToDefault(true) ) )
See the configuration XSD and programmatic code generation for more details.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
generationTool { generator { database { inputCatalog = "my_input_catalog" outputCatalogToDefault = true inputSchema = "my_input_schema" outputSchemaToDefault = true } } }
See the configuration XSD and gradle code generation for more details.
Nested
<configuration> <generator> <database> <catalogs> <catalog> <inputCatalog>input_catalog</inputCatalog> <outputCatalogToDefault>true</outputCatalogToDefault> <schemata> <schema> <inputSchema>input_schema1</inputSchema> <outputSchemaToDefault>true</outputSchemaToDefault> </schema> <schema> <inputSchema>input_schema2</inputSchema> <outputSchema>output_schema2</outputSchema> </schema> </schemata> </catalog> </catalogs> </database> </generator> </configuration>
See the configuration XSD, standalone code generation, and maven code generation for more details.
new org.jooq.meta.jaxb.Configuration() .withGenerator(new Generator() .withDatabase(new Database() .withCatalogs( new CatalogMappingType() .withInputCatalog("input_catalog") .withOutputCatalogToDefault(true) .withSchemata( new SchemaMappingType() .withInputSchema("input_schema1") .withOutputSchemaToDefault(true), new SchemaMappingType() .withInputSchema("input_schema2") .withOutputSchema("output_schema2") ) ) ) )
See the configuration XSD and programmatic code generation for more details.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
generationTool { generator { database { catalogs { catalog { inputCatalog = "input_catalog" outputCatalogToDefault = true schemata { schema { inputSchema = "input_schema1" outputSchemaToDefault = true } schema { inputSchema = "input_schema2" outputSchema = "output_schema2" } } } } } } }
See the configuration XSD and gradle code generation for more details.
Feedback
Do you have any feedback about this page? We'd love to hear it!