Originally posted by Loren Rosen:
The usual way to do this is to have a version property on the object, a <version> tag in the mapping file, and a version column in the table in the database. This is incremented very time the object is updated, and hibernate can check that the version numbers match when you do an update. If they don't it will throw a StaleObjectStateException.
You can also have it do the same thing with a timestamp column.
So, we can define optimistic locking on a class level, during updates??