What are the differences between Hibernate saveOrUpdate () and merge () session methods?

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.

+7
source share
3 answers

Even if this is for NHibernate, this also applies to Hibernate:

NHibernate - Difference between session.Merge and session.SaveOrUpdate?

+1
source

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.

+1
source

Hibernate's SaveOrUpdate and Merge explain the differences between saveOrUpdate() and merge() .

+1
source

All Articles