This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.
CRUD: Merge
Supported by ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
A MERGE (or UPSERT) operation can be executed on an org.jooq.UpdatableRecord when it is created in the client irrespective of whether the corresponding record already exists in the database. If it does not exist, the operation will have INSERT semantics. If it does exist, it will have UPDATE semantics.
This is different from store() as the decision will be made in the database, not in the client.
// Create a new record
BookRecord book = create.newRecord(BOOK);
// Merge the record:
// INSERT INTO BOOK (ID, TITLE)
// VALUES (1, '1984')
// ON CONFLICT (ID)
// DO UPDATE SET TITLE = excluded.TITLE
book.steId(1)
book.setTitle("1984");
book.merge();
Some variant of INSERT .. ON DUPLICATE KEY UPDATE will be executed, or its emulation via INSERT .. ON CONFLICT or MERGE.
Feedback
Do you have any feedback about this page? We'd love to hear it!