Available in versions: Dev (3.20) | Latest (3.19) | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11 | 3.10

This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.

Code generation

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

While optional, source code generation is one of jOOQ's main assets if you wish to increase developer productivity. jOOQ's code generator takes your database schema and reverse-engineers it into a set of Java classes modelling tables, records, sequences, POJOs, DAOs, stored procedures, user-defined types and many more.

The essential ideas behind source code generation are these:

  • Increased IDE support: Type your Java code directly against your database schema, with all type information available
  • Type-safety: When your database schema changes, your generated code will change as well. Removing columns will lead to compilation errors, which you can detect early.

The following chapters will show how to configure the code generator and how to generate various artefacts.

Table of contents

6.1.
Configuration and setup of the generator
6.2.
Advanced generator configuration
6.2.1.
Logging
6.2.2.
Error handling
6.2.3.
Jdbc
6.2.4.
Generator
6.2.5.
Database
6.2.5.1.
Database name and properties
6.2.5.2.
Inline database implementation
6.2.5.3.
RegexFlags
6.2.5.4.
Includes and Excludes
6.2.5.5.
Include object types
6.2.5.6.
Record Version and Timestamp Fields
6.2.5.7.
Comments
6.2.5.8.
Synthetic objects
6.2.5.8.1.
Synthetic columns
6.2.5.8.2.
Synthetic readonly columns
6.2.5.8.3.
Synthetic readonly ROWIDs
6.2.5.8.4.
Synthetic identities
6.2.5.8.5.
Synthetic enums
6.2.5.8.6.
Synthetic primary keys
6.2.5.8.7.
Synthetic unique keys
6.2.5.8.8.
Synthetic foreign keys
6.2.5.9.
Date as timestamp
6.2.5.10.
Ignore procedure return values (deprecated)
6.2.5.11.
Hidden columns (new)
6.2.5.12.
Readonly columns
6.2.5.13.
Unsigned types
6.2.5.14.
Catalog and schema mapping
6.2.5.15.
Catalog and schema version providers
6.2.5.16.
Custom ordering of generated code
6.2.5.17.
Forced types
6.2.5.17.1.
Matching of forced types
6.2.5.17.2.
Data type rewriting
6.2.5.17.3.
Qualified converters
6.2.5.17.4.
Inline converters
6.2.5.17.5.
Lambda converters
6.2.5.17.6.
Auto converters
6.2.5.17.7.
Enum converters
6.2.5.17.8.
Jackson converters
6.2.5.17.9.
JAXB converters
6.2.5.17.10.
Data type bindings
6.2.5.17.11.
Client side computed columns
6.2.5.17.12.
Audit columns
6.2.5.17.13.
Hidden columns (new)
6.2.5.17.14.
Visibility Modifier (per forced type)
6.2.5.18.
Table valued functions
6.2.6.
Generate
6.2.6.1.
Annotations
6.2.6.2.
Covariant overrides
6.2.6.2.1.
Overriding as()
6.2.6.2.2.
Overriding rename()
6.2.6.2.3.
Overriding where()
6.2.6.3.
Default catalog and schema
6.2.6.4.
Extended types
6.2.6.5.
Fluent setters
6.2.6.6.
Fully Qualified Types
6.2.6.7.
Global Artefacts
6.2.6.8.
Global object names
6.2.6.9.
Implicit JOIN paths
6.2.6.10.
Java Time Types
6.2.6.11.
Serial Version UID
6.2.6.12.
Sources
6.2.6.13.
Text blocks
6.2.6.14.
Visibility Modifier (global)
6.2.6.15.
Whitespace (newlines and indentation)
6.2.6.16.
Zero Scale Decimal Types
6.2.7.
Output target configuration
6.3.
Programmatic generator configuration
6.4.
Custom generator strategies
6.5.
Matcher strategies
6.5.1.
MatcherRule
6.5.2.
Matching catalogs
6.5.3.
Matching schemas
6.5.4.
Matching tables
6.5.5.
Matching fields
6.5.6.
Matching indexes
6.5.7.
Matching primary keys
6.5.8.
Matching unique keys
6.5.9.
Matching foreign keys
6.5.10.
Matching routines
6.5.11.
Matching sequences
6.5.12.
Matching enums
6.5.13.
Matching embeddables
6.5.14.
Matching UDTs
6.5.15.
Matching attributes
6.5.16.
Matcher examples
6.6.
Custom code sections
6.7.
Generated global artefacts
6.8.
Generated tables
6.9.
Generated records
6.10.
Generated POJOs
6.11.
Generated Interfaces
6.12.
Generated DAOs
6.13.
Generated sequences
6.14.
Generated procedures
6.15.
Generated domains
6.16.
Generated UDTs
6.17.
Data type extensions
6.17.1.
PostgreSQL
6.18.
Embeddable types
6.18.1.
Configuration
6.18.2.
Overlapping embeddable types
6.18.3.
Field replacement
6.18.4.
Embedded keys
6.18.5.
Embedded domains
6.19.
Mapping generated catalogs and schemas
6.20.
Code generation for large schemas
6.21.
Code generation and version control
6.22.
JPADatabase: Code generation from entities
6.23.
XMLDatabase: Code generation from XML files
6.24.
DDLDatabase: Code generation from SQL files
6.25.
LiquibaseDatabase: Code generation from Liquibase XML, YAML, JSON files
6.26.
XMLGenerator: Generating XML
6.27.
KotlinGenerator
6.28.
ScalaGenerator
6.29.
Running the code generator with Maven
6.30.
Running the code generator with Ant
6.31.
Running the code generator with Gradle
6.32.
System properties governing code generation
6.33.
In-memory compilation of programmatic configuration
6.34.
Features requiring generated code

previous : next

Feedback

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

The jOOQ Logo