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.
Readonly column behaviour
Applies to ❌ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
When using is readonly columns, by default, any values that are attempted to be inserted or updated are ignored. The following Settings
allow for overriding and the default behaviour of readonly columns:
-
Settings.readonlyInsert
: In an INSERT statement, or in theINSERT
clause of a MERGE statement. -
Settings.readonlyUpdate
: In an UPDATE statement, or in theUPDATE
clause of a MERGE statement. -
Settings.readonlyTableRecordInsert
: In aTableRecord.insert()
operation, or theINSERT
part or execution ofTableRecord.store()
orUpdatableRecord.merge()
. If this is deactivated,Settings.readonlyInsert
still applies -
Settings.readonlyUpdatableRecordUpdate
: In aUpdatableRecord.update()
operation, or theUPDATE
part or execution ofTableRecord.store()
orUpdatableRecord.merge()
. If this is deactivated,Settings.readonlyUpdate
still applies
Each one of these flags is of type org.jooq.conf.WriteIfReadonly
with these permitted states:
-
WRITE
: Write to the column as if it weren't readonly. This effectively turns off the feature. -
IGNORE
: Ignore the column in a relevant statement. This is the default. -
THROW
: Throw an exception if the column is included in a relevant DML statement.
The default behaviour IGNORE
is particularly useful when loading POJO data into org.jooq.UpdatableRecord
and storing it, while ignoring IDENTITY
columns, computed columns, synthetic columns (such as the synthetic ROWIDs), and more.
Example configuration
Settings settings = new Settings() .withReadonlyInsert(WriteIfReadonly.THROW) // Defaults to IGNORE .withReadonlyUpdate(WriteIfReadonly.THROW) // Defaults to IGNORE .withReadonlyTableRecordInsert(WriteIfReadonly.THROW) // Defaults to IGNORE .withReadonlyUpdatableRecordUpdate(WriteIfReadonly.THROW); // Defaults to IGNORE
Feedback
Do you have any feedback about this page? We'd love to hear it!