New versions: Dev (3.15) | Latest (3.14) | 3.13 | 3.12 | 3.11 | 3.10 | 3.9 | 3.8 | Old versions: 3.7 | 3.6 | 3.5 | 3.4 | 3.3 | 2.6

Mapping generated schemata and tables

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

We've seen previously in the chapter about runtime schema mapping, that schemata and tables can be mapped at runtime to other names. But you can also hard-wire 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.

XML (standalone and maven)
Programmatic
Gradle
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.8.7.xsd">
  <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>
new org.jooq.util.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")
      )
    )
  )
myConfigurationName(sourceSets.main) {
  generator {
    database {
      schemata {
        schema {

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

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

Feedback

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

The jOOQ Logo