What is the difference between merge and update method?



What is the difference between merge and update method?..

Answer / Avanish Kumar

In Hibernate, the merge() method merges a detached object (not associated with any Session) into the persistence context. If the object already exists in the database, the changes made to the detached object are applied, otherwise a new object is created and saved. The update() method, on the other hand, updates an existing persistent object without checking if it's associated with a current Hibernate Session.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Hibernate Interview Questions

Difference between load and get?

1 Answers  


What are the core interfaces of hibernate?

1 Answers  


How can the primary key be created by using hibernate?

1 Answers  


What inheritance mapping strategies are available in hibernate?

1 Answers  


What is criteria in hibernate?

1 Answers  


What is disadvantage of hibernate?

1 Answers  


What is collection mapping?

1 Answers  


What is dialect in hibernate?

1 Answers  


Which annotation is used to auto generate primary key?

1 Answers  


What is the role of session interface in hibernate?

1 Answers  


How does hibernate mapping work?

1 Answers  


What is the difference between and merge and update?

1 Answers  


Categories