merge() method in Hibernate

merge(): It merge the detached object data into persistent data.

Lets understand merge() method by example. Employee table in database

 

Output in Eclipse

Employee table in database,After execution of above program  

Before 23rd line, emp1 is in Persistent state and emp2 is in detached state. In 23rd line, merge() method […]