jOOQ has this nice feature of letting you map results into a data class:
data class User(id: Int, email: String)
val users: List<User> = ctx.select().from(USERS).fetchInto(User::class.java)
Is there a similar way to write an insert
using an automatic data mapping from a data class?
How about an update
?
The inverse of calling the various "into" methods, such as
ResultQuery.fetchInto(Class)
is to load data into a record using various "from" methods, e.g.Record.from(Object)
orDSLContext.newRecord(Table, Object)
, so:Since your data class has no notion of "dirty flag", this will always set all the values in the
UserRecord
toRecord.changed() == true
. You can reset the changed flag if required.