Available in versions: Dev (3.18) | Latest (3.17) | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11 | 3.10 | 3.9 | 3.8
Advanced generator configuration
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
In the previous section we have seen how jOOQ's source code generator is configured and run within a few steps. In this chapter we'll cover some advanced settings
jooq-meta configuration
Within the <generator/> element, there are other configuration elements:
<!-- These properties can be added to the database element: --> <database> <!-- This flag indicates whether include / exclude patterns should also match columns within tables. --> <includeExcludeColumns>false</includeExcludeColumns> <!-- All table and view columns that are used as "version" fields for optimistic locking (A Java regular expression. Use the pipe to separate several expressions). See UpdatableRecord.store() and UpdatableRecord.delete() for details --> <recordVersionFields>REC_VERSION</recordVersionFields> <!-- All table and view columns that are used as "timestamp" fields for optimistic locking (A Java regular expression. Use the pipe to separate several expressions). See UpdatableRecord.store() and UpdatableRecord.delete() for details --> <recordTimestampFields>REC_TIMESTAMP</recordTimestampFields> <!-- A regular expression matching all columns that participate in "synthetic" primary keys, which should be placed on generated UpdatableRecords, to be used with - UpdatableRecord.store() - UpdatableRecord.update() - UpdatableRecord.delete() - UpdatableRecord.refresh() Synthetic primary keys will override existing primary keys. --> <syntheticPrimaryKeys>SCHEMA\.TABLE\.COLUMN(1|2)</syntheticPrimaryKeys> <!-- All (UNIQUE) key names that should be used instead of primary keys on generated UpdatableRecords, to be used with - UpdatableRecord.store() - UpdatableRecord.update() - UpdatableRecord.delete() - UpdatableRecord.refresh() If several keys match, a warning is emitted and the first one encountered will be used. This flag will also replace synthetic primary keys, if it matches. --> <overridePrimaryKeys>MY_UNIQUE_KEY_NAME</overridePrimaryKeys> <!-- Generate java.sql.Timestamp fields for DATE columns. This is particularly useful for Oracle databases. With jOOQ 3.5, this flag has been deprecated. Use an org.jooq.Binding instead Defaults to false --> <dateAsTimestamp>false</dateAsTimestamp> <!-- Generate jOOU data types for your unsigned data types, which are not natively supported in Java. Defaults to true --> <unsignedTypes>true</unsignedTypes> <!-- The schema that is used in generated source code. This will be the production schema. Use this to override your local development schema name for source code generation. If not specified, this will be the same as the input-schema. This will be ignored if outputSchemaToDefault is set to true --> <outputSchema>[your database schema / owner / name]</outputSchema> <!-- A flag to indicate that the outputSchema should be the "default" schema, which generates schema-less, unqualified tables, procedures, etc. --> <outputSchemaToDefault>false</outputSchemaToDefault> <!-- A configuration element to configure several input and/or output schemata for jooq-meta, in case you're using jooq-meta in a multi- schema environment. This cannot be combined with the above inputSchema / outputSchema --> <schemata> <schema> <inputSchema>...</inputSchema> <outputSchema>...</outputSchema> <outputSchemaToDefault>...</outputSchemaToDefault> </schema> [ <schema>...</schema> ... ] </schemata> <!-- A custom version number that, if available, will be used to assess whether the above <inputSchema/> will need to be regenerated. There are three operation modes for this element: - The value is a class that can be found on the classpath and that implements org.jooq.util.CatalogVersionProvider or, respectively, org.jooq.util.SchemaVersionProvider. Such classes must provide a default constructor - The value is a SELECT statement that returns one record with one column. The SELECT statement may contain a named variable called :catalog_name or :schema_name respectively - The value is a constant, such as a Maven property Schema versions will be generated into the javax.annotation.Generated annotation on generated artefacts. --> <catalogVersionProvider>SELECT :catalog_name || '_' || MAX("version") FROM "schema_version"</catalogVersionProvider> <schemaVersionProvider>SELECT :schema_name || '_' || MAX("version") FROM "schema_version"</schemaVersionProvider> <!-- A configuration element to configure reusable custom data types --> <customTypes>...</customTypes> <!-- A configuration element to configure type overrides for generated artefacts (e.g. in combination with customTypes) --> <forcedTypes>...</forcedTypes> </database>
Check out the some of the manual's "advanced" sections to find out more about the advanced configuration parameters.
jooq-codegen configuration
Also, you can add some optional advanced configuration parameters for the generator:
<!-- These properties can be added to the generate element: --> <generate> <!-- Primary key / foreign key relations should be generated and used. This is a prerequisite for various advanced features. Defaults to true --> <relations>true</relations> <!-- Generate deprecated code for backwards compatibility Defaults to true --> <deprecated>true</deprecated> <!-- Do not reuse this property. It is deprecated as of jOOQ 3.3.0 --> <instanceFields>true</instanceFields> <!-- Generate the javax.annotation.Generated annotation to indicate jOOQ version used for source code. Defaults to true --> <generatedAnnotation>true</generatedAnnotation> <!-- Generate jOOQ Record classes for type-safe querying. You can turn this off, if you don't need "active records" for CRUD Defaults to true --> <records>true</records> <!-- Generate POJOs in addition to Record classes for usage of the ResultQuery.fetchInto(Class) API Defaults to false --> <pojos>false</pojos> <!-- Generate immutable POJOs for usage of the ResultQuery.fetchInto(Class) API This overrides any value set in <pojos/> Defaults to false --> <immutablePojos>false</immutablePojos> <!-- Generate interfaces that will be implemented by records and/or pojos. You can also use these interfaces in Record.into(Class<?>) and similar methods, to let jOOQ return proxy objects for them. Defaults to false --> <interfaces>false</interfaces> <!-- Generate DAOs in addition to POJO classes Defaults to false --> <daos>false</daos> <!-- Annotate POJOs and Records with JPA annotations for increased compatibility and better integration with JPA/Hibernate, etc Defaults to false --> <jpaAnnotations>false</jpaAnnotations> <!-- Annotate POJOs and Records with JSR-303 validation annotations Defaults to false --> <validationAnnotations>false</validationAnnotations> <!-- Annotate DAOs with useful spring annotations such as @Repository or @Autowired Defaults to false --> <springAnnotations>false</springAnnotations> <!-- Allow to turn off the generation of global object references, which include - Tables.java - Sequences.java - UDTs.java Turning off the generation of the above files may be necessary for very large schemas, which exceed the amount of allowed constants in a class's constant pool (64k) or, whose static initialiser would exceed 64k of byte code Defaults to true --> <globalObjectReferences>true</globalObjectReferences> <!-- Generate fluent setters in - records - pojos - interfaces Fluent setters are against the JavaBeans specification, but can be quite useful to those users who do not depend on EL, JSP, JSF, etc. Defaults to false --> <fluentSetters>false</fluentSetters> </generate>
Property interdependencies
Some of the above properties depend on other properties to work correctly. For instance, when generating immutable pojos, pojos must be generated. jOOQ will enforce such properties even if you tell it otherwise. Here is a list of property interdependencies:
- When
daos = true
, then jOOQ will setrelations = true
- When
daos = true
, then jOOQ will setrecords = true
- When
daos = true
, then jOOQ will setpojos = true
- When
immutablePojos = true
, then jOOQ will setpojos = true
References to this page
Feedback
Do you have any feedback about this page? We'd love to hear it!