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

Mapping generated catalogs and schemas

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

We've seen previously in the chapter about runtime schema mapping, that catalogs, schemata and tables can be mapped at runtime to other names. But you can also hard-wire catalog and schema mapping in generated artefacts at code generation time, e.g. when you have 5 developers with their own dedicated developer databases, and a common integration database. In the code generation configuration, you would then write.

Schema mapping

The following configuration applies mapping only for schemata, not for catalogs. The <schemata/> element is a standalone element that can be put in the code generator's <database/> configuration element:

XML (standalone and maven)
Programmatic
Gradle (Kotlin)
Gradle (Groovy)
Gradle (third party)
<configuration>
  <generator>
    <database>
      <schemata>
        <schema>

          <!-- Use this as the developer's schema: -->
          <inputSchema>LUKAS_DEV_SCHEMA</inputSchema>

          <!-- Use this as the integration / production database: -->
          <outputSchema>PROD</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()

          // Use this as the developer's schema:
          .withInputSchema("LUKAS_DEV_SCHEMA")

          // Use this as the integration / production database:
          .withOutputSchema("PROD")
      )
    )
  )

See the configuration XSD and programmatic code generation for more details.

import org.jooq.meta.jaxb.*


configuration {
  generator {
    database {
      schemata {
        schema {

          // Use this as the developer's schema:
          inputSchema = "LUKAS_DEV_SCHEMA"

          // Use this as the integration / production database:
          outputSchema = "PROD"
        }
      }
    }
  }
}

See the configuration XSD and gradle code generation for more details.

configuration {
  generator {
    database {
      schemata {
        schema {

          // Use this as the developer's schema:
          inputSchema = "LUKAS_DEV_SCHEMA"

          // Use this as the integration / production database:
          outputSchema = "PROD"
        }
      }
    }
  }
}

See the configuration XSD and gradle code generation for more details.

// The jOOQ-codegen-gradle plugin has been introduced in version 3.19.
// Please use the official plugin instead of the third party plugin that was recommended before.

The following configuration applies mapping for catalogs and their schemata. The <catalogs/> element is a standalone element that can be put in the code generator's <database/> configuration element:

XML (standalone and maven)
Programmatic
Gradle (Kotlin)
Gradle (Groovy)
Gradle (third party)
<configuration>
  <generator>
    <database>
      <catalogs>
        <catalog>

          <!-- Use this as the developer's catalog: -->
          <inputCatalog>LUKAS_DEV_CATALOG</inputCatalog>

          <!-- Use this as the integration / production database: -->
          <outputCatalog>PROD</outputCatalog>

          <!-- Optionally, nest also schema mapping configurations: -->
          <schemata>
          </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()

          // Use this as the developer's catalog:
          .withInputCatalog("LUKAS_DEV_CATALOG")

          // Use this as the integration / production database:
          .withOutputCatalog("PROD")

          // Optionally, nest also schema mapping configurations:
          .withSchemata()
      )
    )
  )

See the configuration XSD and programmatic code generation for more details.

import org.jooq.meta.jaxb.*


configuration {
  generator {
    database {
      catalogs {
        catalog {

          // Use this as the developer's catalog:
          inputCatalog = "LUKAS_DEV_CATALOG"

          // Use this as the integration / production database:
          outputCatalog = "PROD"

          // Optionally, nest also schema mapping configurations:
          schemata {}
        }
      }
    }
  }
}

See the configuration XSD and gradle code generation for more details.

configuration {
  generator {
    database {
      catalogs {
        catalog {

          // Use this as the developer's catalog:
          inputCatalog = "LUKAS_DEV_CATALOG"

          // Use this as the integration / production database:
          outputCatalog = "PROD"

          // Optionally, nest also schema mapping configurations:
          schemata {}
        }
      }
    }
  }
}

See the configuration XSD and gradle code generation for more details.

// The jOOQ-codegen-gradle plugin has been introduced in version 3.19.
// Please use the official plugin instead of the third party plugin that was recommended before.

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo