Friday, 31 July 2015

Difference between update() and merge() in Hibernate

Hibernate has different methods to save, fetch, update and delete object. Commonly or the most popular methods to update the data are update() and merge(). The update() method is widely used to update the record while the merge() method is less, because very few users has knowledge about the merge() method. Some of programmers having confusions where to use update() and where should use the merge() method.
In this article we will show you how update() is different from the merge() method. Difference between update() and merge() is as follows:
update() and merge() both methods are used to update the db row if it already exist. But if object does not exist in db already then the update() method will throw the exception while merge() will create the new entry in db for that object.

For full blog about Difference between update() and merge() method visit FindNerd.

Findnerd allow users to ask questions on various programming languages for ex- java questions and answers is one of them, and the best thing about FindNerd is- its response time.The developer community of FindNerd consists of experienced developers in various fields and are ready to help you.

No comments:

Post a Comment