I will be using Session per request pattern for my application. My question is more of a doubt on how optimistic concurrency works and less about Hibernate.
I am using a dedicated timestamp column with source="db" and generated="always".
Consider the following scenario:
User 1 in session 1 creates a new object foo and saves it. timestamp = 1 is set by DB.
User 2 in session 2 retrieves foo, updates a property of foo and saves it using session2.update. timestamp = 2 is set by DB (?)
User 1 in session 3 tries to reattach the detached object (which was created in session 1 i.e. the one with timestamp = 1) using session3.update.
Now when session3 is flushed, will Hibernate throw exception because of timestamp mismatch?
|