What are the differences between Hibernate Session methods saveOrUpdate(Object) and merge(Object)? It seems that both methods generate an SQL INSERT statement when the given object does not exist in the corresponding table and an UPDATE when it does exist.
Even though this is for NHibernate, it also applies to Hibernate:
NHibernate - Difference between session.Merge and session.SaveOrUpdate?
If I remember correctly, merge is for un-associated instances, that aren't currently managed. It will do a lookup based on id and merge the two.
SaveOrUpdate versus Merge in Hibernate explains the differences between saveOrUpdate()
and merge()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With