david wrote:
Hibernate has a mapping tag to map a field as the optimistic locking field. In this case its <timestamp>. When you do the update hibernate will check the value against the database for you and throw an exception if the lock guard has changed. All automatically.
But what happen if I have an ID of the object but not the object itself? To update it I need to get it first from somewhere. The question is, if I have an ID of the object (but don't have a timestamp or version) and I loaded it before (and didn't evict it) is there any way to get it from the cache rather than from DB even if the data is stale?