The jOOQ User Manual : Code generation : Advanced generator configuration : Database : Record Version and Timestamp Fields | previous : next |
Record Version and Timestamp Fields
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
jOOQ's org.jooq.UpdatableRecord supports an optimistic locking feature, which can be enabled in the code generator by specifying a regular expression that defines such a record's version and/or timestamp fields. These regular expressions should match at most one column per table, again either by their fully qualified names (catalog.schema.table.column_name) or by their names only (column_name):
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.14.0.xsd"> <generator> <database> <recordVersionFields>REC_VERSION</recordVersionFields> <recordTimestampFields>REC_TIMESTAMP</recordTimestampFields> </database> </generator> </configuration>
new org.jooq.meta.jaxb.Configuration() .withGenerator(new Generator() .withDatabase(new Database() .withRecordVersionFields("REC_VERSION") .withRecordTimestampFields("REC_TIMESTAMP") ) )
myConfigurationName(sourceSets.main) { generator { database { recordVersionFields = 'REC_VERSION' recordTimestampFields = 'REC_TIMESTAMP' } } }
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!