简体   繁体   中英

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

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与Hibernate中的Merge解释了saveOrUpdate()merge()之间的区别。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM