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 |
Can we delete foreign key?
What is difference between hibernate save(), saveorupdate() and persist() methods?
Why do we need orm tools like hibernate?
What is a many-to-one association in hibernate?
What is the root element for the hibernate mapping file?
What is hibernate in java?
What is hibernate ogm?
How properties of a class are mapped to the columns of a database table in hibernate?
What role does the session interface play in hibernate?
What are the states of the object in hibernate?
What are different types of second level cache?
Which element of hbm.xml is used to map a java.util.set property in hibernate?