Readonly column behaviour
Supported by ❌ 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 theINSERTclause of a MERGE statement. -
Settings.readonlyUpdate: In an UPDATE statement, or in theUPDATEclause of a MERGE statement. -
Settings.readonlyTableRecordInsert: In aTableRecord.insert()operation, or theINSERTpart or execution ofTableRecord.store()orUpdatableRecord.merge(). If this is deactivated,Settings.readonlyInsertstill applies -
Settings.readonlyUpdatableRecordUpdate: In aUpdatableRecord.update()operation, or theUPDATEpart or execution ofTableRecord.store()orUpdatableRecord.merge(). If this is deactivated,Settings.readonlyUpdatestill 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!