From this SO answer:
The update() method forces an update to the persistent state of the object in the database, always scheduling an SQL UPDATE. ... It doesn’t matter if the item object is modified before or after it’s passed to update(). ... Hibernate always treats the object as dirty and schedules an SQL UPDATE., which will be executed during flush. On the other hand, merge() queries the database first, and doesn't perform update if state haven't changed.
A doubt emerged in my mind:
How is Hibernate (or any JPA implementation) able to tell if the state of an entity has changed so that an update operation is needed ?
Should we implement equals or hashcode method to help Hibernate to do so ?
What if do not implement those methods ?