What is the difference between Hibernate Session saveOrUpdate (Object) and merge (Object) methods? Both methods seem to generate SQL INSERT when the given object does not exist in the corresponding table, and UPDATE when it exists.
Even if this is for NHibernate, this also applies to Hibernate:
NHibernate - Difference between session.Merge and session.SaveOrUpdate?
If I remember correctly, merging occurs for unrelated instances that are not currently managed. It will do an id based search and combine the two.
Hibernate's SaveOrUpdate and Merge explain the differences between saveOrUpdate() and merge() .
saveOrUpdate()
merge()