One correction first: Merge is also used for transient instances (Instances which haven't been saved at all yet).
When you have a new hibernate session with detached instance of object A, it doesn't matter in most cases if you use merge() or update() to save the changes. So in your example, calling merge() or update() would yield the exact same result.
However, if you have two objects with the same identifiers where one of them is detached and the other one is persistent, calling update() on the detached instance will throw an exception where merge will save the changes.
Oh, and one more thing. Merge() saves the _STATE_ of the object, so the member variables are saved to the db and the function returns the persistent instance while update() will save the object itself and make it persistent.
Hope this helps :)
|