The jOOQ User Manual : Code generation : Advanced generator configuration : Database : Synthetic objects : Synthetic readonly ROWIDs | previous : next |
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.
Synthetic readonly ROWIDs
Applies to ❌ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
A few database products support a ROWID
type, which models a physical location of a row on the disk. A ROWID
can act like a primary key, e.g. in the absence of a formal primary key, although being a physical address, rather than a logical one, there is usually no guarantee of a ROWID
to never change. For short-lived record access, this may be irrelevant (e.g. within a single query, for faster self-joins).
jOOQ's code generator allows for specifying a synthetic ROWID configuration that produces such ROWID
columns on all tables that it matches. Combine this with the synthetic primary key feature, and you can replace a potentially existing primary key for all interactions with the row, including e.g. CRUD with UpdatableRecords (some vendor specific limitations may apply).
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.16.5.xsd"> <generator> <database> <syntheticObjects> <readonlyRowids> <readonlyRowid> <!-- Optional name of the column in generated code. --> <name>ROWID</name> <!-- Regular expression matching all tables that have this synthetic ROWID. --> <tables>SCHEMA\.TABLE</tables> </readonlyRowid> </readonlyRowids> </syntheticObjects> </database> </generator> </configuration>
new org.jooq.meta.jaxb.Configuration() .withGenerator(new Generator() .withDatabase(new Database() .withSyntheticObjects(new SyntheticObjectsType() .withReadonlyRowids( new SyntheticReadonlyRowidType() // Optional name of the column in generated code. .withName("ROWID") // Regular expression matching all tables that have this synthetic ROWID. .withTables("SCHEMA\\.TABLE") ) ) ) )
myConfigurationName(sourceSets.main) { generator { database { syntheticObjects { readonlyRowids { readonlyRowid { // Optional name of the column in generated code. name = 'ROWID' // Regular expression matching all tables that have this synthetic ROWID. tables = 'SCHEMA\\.TABLE' } } } } } }
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!