Thanks for your reply Froestel.
I have previously read those parts of the doc but I don't really see where they explain the difference between the 2 i.e why merge takes immediate effect whilst update don't. But maybe I'm missing something.
merge explained in "Automatic state detection" part:
Quote:
if there is a persistent instance with the same identifier currently associated with the session, copy the state of the given object onto the persistent instance
if there is no persistent instance currently associated with the session, try to load it from the database, or create a new persistent instance
...
...
1. The loading from the database will perform a flush, right?
2. if there is an existing persistent instance the changes in the versioned property will be detected at copy time?
Is this correct? I'm just guessing. Or do you mean that merge is doing an instant flush no matter what?
By the way this is exactly what I'm doing:
Quote:
Usually update() or saveOrUpdate() are used in the following scenario:
the application loads an object in the first session
the object is passed up to the UI tier
some modifications are made to the object
the object is passed back down to the business logic tier
the application persists these modifications by calling update() in a second session
The main reason for asking this queston is that I want to know if merge is the only reasonable option in my case, and if I can trust merge always to throw an exception instantly i.e not wait until a flush. (Actually I would rather not use merge at all in this case)