[hibernate-dev] [ORM] Support for upsert semantics

Gunnar Morling gunnar at hibernate.org
Tue Sep 11 05:31:21 EDT 2018


Hi,

A common requirement that comes up repeatedly is "upsert" operations, i.e.
either insert a record or update the existing one with the same PK, if it
already exists. Many (most?) RDBMS support it, either by implementing SQL
2003's MERGE keyword or via proprietary alternatives [1].

I think it'd be great if there was something like Session#upsert(),
exposing these semantics at the entity level. Perhaps the idea was already
brought up in the past, but I wanted to throw it out in any case.

Any thoughts?

Cheers,

--Gunnar

[1]
https://vladmihalcea.com/how-do-upsert-and-merge-work-in-oracle-sql-server-postgresql-and-mysql/


More information about the hibernate-dev mailing list