Regular |
|
Joined: Wed Jan 07, 2004 5:16 pm Posts: 65 Location: CA, USA
|
If you are using optimistic locking when you update a previously loaded entity you'll find out if someone/something already updated the current row after you last read the row (because the update will fail). This is typically acceptable behavior in web applications because it maintains concurrency by avoiding pessimistic locks on the database.
This however does not address your concern of how do you know if someone else updated a row and how do you retrieve the latest data. You could do this by calling session.refresh() periodically on your entity, but of course you'll pay in the performance hit by doing this depending on how often you call this.
In web-apps it is accepted with optimistic locking that at anytime you may have stale data - this cost is preferable to ensure high concurrency rather than correct data with pessimistic db locks but low concurrency. The approach depends on what you are looking for.
|
|