upserts #5412
Replies: 3 comments 2 replies
-
IMO we have to first understand what Some thoughts:
|
Beta Was this translation helpful? Give feedback.
-
Note also that this potentially provides a (much better) replacement for |
Beta Was this translation helpful? Give feedback.
-
Is there an update on an upsert / ON CONFLICT implementation in Hibernate? |
Beta Was this translation helpful? Give feedback.
-
Some databases have the ability to do
insert
orupdate
depending on whether a row already exists. This is something where we could pretty easily abstract the syntax differences between databases (and fall back to using two statements when there's no way to do it in one statement).And I think this is something that's pretty useful at times. In particular I think it's very useful when processing batches of data.
So if we do this, the question is: how would we expose this to the user?
upsert()
toStatelessSession
.merge()
use upserts instead of fetching and then updating? I find the idea very appealing, but I strongly suspect it's very tricky. It runs into some of the same sorts of issues that I had to deal with for "delete without loading". But then, I managed to deal with those issues forremove()
, so perhaps I could do similar tricks formerge()
.Indeed, 1 and 2 together seem to sort-of make sense:
upsert()
is naturally the stateless-session version ofmerge()
!Thoughts?
(P.S. This was a feature suggestion from users who talked to me at Devoxx.)
Beta Was this translation helpful? Give feedback.
All reactions