What is difference between merge and saveorupdate in hibernate?



What is difference between merge and saveorupdate in hibernate?..

Answer / Ankit Verma

In Hibernate, both merge() and saveOrUpdate() are used to persist or update an object. However, there is a subtle difference between them:n- merge(): Merges the state of the given transient instance with the persistent instance in the database if it exists. If the instance is not persistent, a new persistent instance will be created.n- saveOrUpdate(): Saves the transient instance or updates the persistent instance if it already exists in the database.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Hibernate Interview Questions

Can we delete foreign key?

1 Answers  


What is difference between hibernate save(), saveorupdate() and persist() methods?

1 Answers  


Why do we need orm tools like hibernate?

1 Answers  


What is a many-to-one association in hibernate?

1 Answers  


What is the root element for the hibernate mapping file?

1 Answers  


What is hibernate in java?

1 Answers  


What is hibernate ogm?

1 Answers  


How properties of a class are mapped to the columns of a database table in hibernate?

1 Answers  


What role does the session interface play in hibernate?

1 Answers  


What are the states of the object in hibernate?

1 Answers  


What are different types of second level cache?

1 Answers  


Which element of hbm.xml is used to map a java.util.set property in hibernate?

1 Answers  


Categories