I am trying to perform an UPSERT in PostgreSQL using the jOOQ library.
For doing this I am currently trying to implement the following SQL statement in jOOQ: https://st
Inspired by @ud3sh comment with JOOQ 3.11, Kotlin, and the PostgreSQL DSL
This is an extension function to call upsert
directly on the UpdatableRecord
object
import org.jooq.UpdatableRecord
internal fun UpdatableRecord<*>.upsert(): Int {
if(this.configuration() == null) {
throw NullPointerException("Attach configuration to record before calling upsert")
}
return this.configuration().dsl().insertInto(this.getTable()).set(this).onConflict().doUpdate().set(this).execute()
}