I'm working with a client who is using Hibernate. They have NOT implemented any locking strategies yet as it is a low contention site. Once they get the site up and running, it will be a very high volume site (but still low contention). Consequently their architecture specifies both a stateless app server (Websphere) and a stateless UI Server (Tomcat). As a result they use stateless session beans and don't allow anything in HttpSession. All state has to be in cookies, hidden fields, or database records.
I want them to implement a locking strategy to make their application more robust. Optimistic locking will do the trick for them. My reading of Optimisitc Locking (yes, I've read the manual and browsed the forums) is that the preferred method is a version column. And if you use that, you must hang onto it when you get the objects. For a statefull sessions, this is not a problem in that you simply hang onto the objects returned by find() / load() / query(). For stateless sessions, you must now hang onto this version (as a hidden field in the web page) and repopulate the version property (column) with this value after doing a get() or load() in order for the lock to work correctly. If you didn't repopulate the version column, then you may be getting a object that is more current than the one you displayed in the UI.
Is my reading of the use of optimistic locking correct?
Jerome Dayton-
|