Once a session is closed. The application may have detached object provided its not evicted in session. Now in the mean time, some modifications happen to the corresponding persistent object and is saved back to the database. Now we open up new session and attach the detached object to session using session.merge(obj). Now as per my understanding, this time we we will get an exception and our commit would fail as versioning is changed since the first time the object was read into memory(which became datached object) till the time we are attaching it to session using session.merge()
If my understanding is correct then, we cant use detached objects in clustered web environment where several threads might be accessing/modifying database objects. How to deal with this situation?
|