I want to update row if it exists otherwise insert it. Is there any convenience method like hibernate's saveOrUpdate in jooq?
Currently i am checking in database if it exists then run update query otherwise insert it.
You can use one of the different UPSERT
statements supported by jOOQ, depending on your RDBMS:
INSERT .. ON DUPLICATE KEY UPDATE
as supported natively by MySQL. It can be emulated using both of the following optionsINSERT .. ON CONFLICT DO UPDATE
as supported natively by PostgreSQL. It can be emulated using the following optionMERGE
as supported natively by many RDBMS and the SQL standard