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
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
- 5.1.
- Configuration and setup of the generator
- 5.2.
- Advanced generator configuration
- 5.2.1.
- Logging
- 5.2.2.
- Error handling
- 5.2.3.
- Jdbc
- 5.2.4.
- Generator
- 5.2.5.
- Database
- 5.2.5.1.
- Database name and properties
- 5.2.5.2.
- RegexFlags
- 5.2.5.3.
- Includes and Excludes
- 5.2.5.4.
- Include object types
- 5.2.5.5.
- Record Version and Timestamp Fields
- 5.2.5.6.
- Comments (new)
- 5.2.5.7.
- Synthetic objects
- 5.2.5.7.1.
- Synthetic identities
- 5.2.5.7.2.
- Synthetic primary keys
- 5.2.5.7.3.
- Synthetic unique keys
- 5.2.5.7.4.
- Synthetic foreign keys
- 5.2.5.8.
- Date as timestamp
- 5.2.5.9.
- Ignore procedure return values (deprecated)
- 5.2.5.10.
- Unsigned types
- 5.2.5.11.
- Catalog and schema mapping
- 5.2.5.12.
- Catalog and schema version providers
- 5.2.5.13.
- Custom ordering of generated code
- 5.2.5.14.
- Forced types
- 5.2.5.14.1.
- Matching of forced types
- 5.2.5.14.2.
- Data type rewriting
- 5.2.5.14.3.
- Qualified converters
- 5.2.5.14.4.
- Inline converters
- 5.2.5.14.5.
- Lambda converters
- 5.2.5.14.6.
- Enum converters
- 5.2.5.14.7.
- Data type bindings
- 5.2.5.15.
- Table valued functions
- 5.2.6.
- Generate
- 5.2.6.1.
- Annotations
- 5.2.6.2.
- Covariant overrides
- 5.2.6.2.1.
- Overriding as()
- 5.2.6.2.2.
- Overriding rename()
- 5.2.6.3.
- Default catalog and schema
- 5.2.6.4.
- Fluent setters
- 5.2.6.5.
- Fully Qualified Types
- 5.2.6.6.
- Global Artefacts
- 5.2.6.7.
- Implicit JOIN paths
- 5.2.6.8.
- Java Time Types
- 5.2.6.9.
- Serial Version UID
- 5.2.6.10.
- Sources
- 5.2.6.11.
- Visibility Modifier (new)
- 5.2.6.12.
- Whitespace (newlines and indentation)
- 5.2.6.13.
- Zero Scale Decimal Types
- 5.2.7.
- Output target configuration
- 5.3.
- Custom code generation dependencies
- 5.4.
- Programmatic generator configuration
- 5.5.
- Custom generator strategies
- 5.6.
- Matcher strategies
- 5.6.1.
- MatcherRule
- 5.6.2.
- Matching catalogs
- 5.6.3.
- Matching schemas
- 5.6.4.
- Matching tables
- 5.6.5.
- Matching fields
- 5.6.6.
- Matching routines
- 5.6.7.
- Matching sequences
- 5.6.8.
- Matching enums
- 5.6.9.
- Matching embeddables
- 5.6.10.
- Matcher examples
- 5.7.
- Custom code sections
- 5.8.
- Generated global artefacts
- 5.9.
- Generated tables
- 5.10.
- Generated records
- 5.11.
- Generated POJOs
- 5.12.
- Generated Interfaces
- 5.13.
- Generated DAOs
- 5.14.
- Generated sequences
- 5.15.
- Generated procedures
- 5.16.
- Generated domains
- 5.17.
- Generated UDTs
- 5.18.
- Data type extensions (new)
- 5.18.1.
- PostgreSQL extensions (new)
- 5.19.
- Embeddable types
- 5.19.1.
- Configuration
- 5.19.2.
- Overlapping embeddable types
- 5.19.3.
- Field replacement
- 5.19.4.
- Embedded keys
- 5.19.5.
- Embedded domains
- 5.20.
- Mapping generated catalogs and schemas
- 5.21.
- Code generation for large schemas
- 5.22.
- Code generation and version control
- 5.23.
- JPADatabase: Code generation from entities
- 5.24.
- XMLDatabase: Code generation from XML files
- 5.25.
- DDLDatabase: Code generation from SQL files
- 5.26.
- LiquibaseDatabase: Code generation from Liquibase XML, YAML, JSON files
- 5.27.
- XMLGenerator: Generating XML
- 5.28.
- KotlinGenerator
- 5.29.
- ScalaGenerator
- 5.30.
- Running the code generator with Maven
- 5.31.
- Running the code generator with Ant
- 5.32.
- Running the code generator with Gradle
- 5.33.
- System properties governing code generation
- 5.34.
- Features requiring generated code
previous : next |
References to this page
- The jOOQ User Manual
- Different use cases for jOOQ
- jOOQ as a SQL builder with code generation
- jOOQ as a SQL executor
- jOOQ for CRUD
- jOOQ for PROs
- Step 3: Code generation
- Using jOOQ with Flyway
- SQL building
- Object qualification
- FROM clause
- Generating DDL from objects
- Catalog and schema expressions
- Generated Tables
- Aliased generated tables
- ON KEY clause
- Array and cursor unnesting
- Table columns
- Generated table columns
- User-defined functions
- User-defined aggregate functions
- BOOLEAN columns
- Record vs. TableRecord
- POJOs
- Sequence execution
- Stored procedures and functions
- Oracle Packages
- Oracle member procedures
- Simple CRUD
- IDENTITY values
- Non-updatable records
- Optimistic locking
- DAOs
Feedback
Do you have any feedback about this page? We'd love to hear it!