Do you mean you open a session in request #1 (i.e., display user for edit) and then reuse it during request #2 (i.e., save posted changes)?
OR are you opening/closing a session during each http request?
All the databases I know of are going to release write locks after the transaction under which the lock was acquired commits or the session (jdbc session) which issued the write lock closes. So this would be a problem with scenario #2.
And even with the first option, you'd run into issues with (hopefully only) the database row being locked during "user think time". I say hopefully, because I don't think all databases support row-level locks, meaning multiple rows or even the whole table would get locked. This is not a scalable solution either way.
The other option here would be to utilize optomistic locks and managing the versioning using Hibernate or in the app itself.
|