Q:

JOOQ: How to add a returning clause when updating through record

I am currently updating table by using:
fun <T: MyRecordInterface<*>> updateRecord(record: T) {
   record.setField1("field1")
   record.setField2("field2")

   record.update()
}

That allow to update different types of record that share the same interface:
updateRecord(myRecord1Instance)
updateRecord(myRecord2Instance)

I would like to return the full updated record after update, so I did:
fun <T: MyRecordInterface<*>> updateRecord(record: T): T {
   record.setField1("field1")
   record.setField2("field2")

   record.update()
   record.refresh()

   return record
}

Is it possible to add returning clause to the update query so that I will not have to issue 2 query in this method ?

A:

You can turn on Settings.returnAllOnUpdatableRecord globally, which will fetch all the resulting values (identities, trigger-generated values, etc.) automatically for you on every store(), insert(), update() call.
This is applied globally, and incurs some overhead, especially if you do not want those resulting values, so it may make sense to use a new Configuration with the above Settings only where this is really needed.

