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
Generated tables
Supported by ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
Every table and view in your database will generate a org.jooq.Table implementation that looks like this:
public class Book extends TableImpl<BookRecord> {
// The singleton instance
public static final Book BOOK = new Book();
// Generated columns
public final TableField<BookRecord, Integer> ID = createField("ID", INTEGER, this);
public final TableField<BookRecord, Integer> AUTHOR_ID = createField("AUTHOR_ID", INTEGER, this);
public final TableField<BookRecord, String> TITLE = createField("TITLE", VARCHAR, this);
// Covariant aliasing method, returning a table of the same type as BOOK
@Override
public Book as(java.lang.String alias) {
return new Book(alias);
}
// [...]
}
Flags influencing generated tables
These flags from the code generation configuration influence generated tables:
- recordVersionFields: Relevant methods from super classes are overridden to return the VERSION field
- recordTimestampFields: Relevant methods from super classes are overridden to return the TIMESTAMP field
- syntheticPrimaryKeys: This overrides existing primary key information to allow for "custom" primary key column sets
- overridePrimaryKeys: This overrides existing primary key information to allow for unique key to primary key promotion
- dateAsTimestamp: This influences all relevant columns
- unsignedTypes: This influences all relevant columns
- relations: Relevant methods from super classes are overridden to provide primary key, unique key, foreign key and identity information
- instanceFields: This flag controls the "static" keyword on table columns, as well as aliasing convenience
- records: The generated record type is referenced from tables allowing for type-safe single-table record fetching
Flags controlling table generation
<configuration>
<generator>
<generate>
<!-- Allows for turning on tables generation: default true -->
<tables>true</tables>
</generate>
</generator>
</configuration>
See the configuration XSD, standalone code generation, and maven code generation for more details.
new org.jooq.meta.jaxb.Configuration()
.withGenerator(
new Generate()
// Allows for turning on tables generation: default true
.withTables(true)
)
See the configuration XSD and programmatic code generation for more details.
import org.jooq.meta.jaxb.*
configuration {
generator {
generate {
// Allows for turning on tables generation: default true
isTables = true
}
}
}
See the configuration XSD and gradle code generation for more details.
configuration {
generator {
generate {
// Allows for turning on tables generation: default true
tables = true
}
}
}
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!