Synthetic columns
Applies to ❌ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
There exist use cases where you want jOOQ's code generator to produce more columns than your meta data source suggests there are, per table. For example:
- Your code generation user doesn't have access to some columns, but your runtime user will have access.
- Your code generation database does not yet / anymore have those columns, but your production system does.
- You're generating client side computed columns, and you want them to have
VIRTUAL
semantics (computation on read), so the columns don't really exist in the schema.
In those cases, you can add synthetic columns to your schema like this:
<configuration> <generator> <database> <syntheticObjects> <columns> <column> <!-- Optional regular expression matching all tables that have this identity. --> <tables>SCHEMA\.TABLE</tables> <!-- The name of the column --> <name>COLUMN</name> <!-- The type of the column --> <type>INTEGER</type> </column> </columns> </syntheticObjects> </database> </generator> </configuration>
See the configuration XSD, standalone code generation, and maven code generation for more details.
new org.jooq.meta.jaxb.Configuration() .withGenerator(new Generator() .withDatabase(new Database() .withSyntheticObjects(new SyntheticObjectsType() .withColumns( new SyntheticColumnType() // Optional regular expression matching all tables that have this identity. .withTables("SCHEMA\\.TABLE") // The name of the column .withName("COLUMN") // The type of the column .withType("INTEGER") ) ) ) )
See the configuration XSD and programmatic code generation for more details.
import org.jooq.meta.jaxb.* configuration { generator { database { syntheticObjects { columns { column { // Optional regular expression matching all tables that have this identity. tables = "SCHEMA\\.TABLE" // The name of the column name = "COLUMN" // The type of the column type = "INTEGER" } } } } } }
See the configuration XSD and gradle code generation for more details.
configuration { generator { database { syntheticObjects { columns { column { // Optional regular expression matching all tables that have this identity. tables = "SCHEMA\\.TABLE" // The name of the column name = "COLUMN" // The type of the column type = "INTEGER" } } } } } }
See the configuration XSD and gradle code generation for more details.
generationTool { generator { database { syntheticObjects { columns { column { // Optional regular expression matching all tables that have this identity. tables = "SCHEMA\\.TABLE" // The name of the column name = "COLUMN" // The type of the column type = "INTEGER" } } } } } }
See the configuration XSD and gradle code generation for more details.
As always, when regular expressions are used, they are regular expressions with default flags.
Feedback
Do you have any feedback about this page? We'd love to hear it!