Hibernate 3.5 has new LockModes, two related to optimistic locks, LockMode.OPTIMISTIC and LockMode.OPTIMISTIC_FORCE_INCREMENT. I'd like to use this lockmodes, to do a version check/upgrade on commit. But when an entity is loaded inside a transaction, its LockMode is set to READ, that has a greater level (See LockMode class). And hibernate does not "downgrade" a lock. Hibernate manual tells that only on REPEATABLE_READ and SERIALIZABLE lockmode is set to READ, but my tests and hibernate code apparently does not... Is this a bug?
I can use this new LockModes evicting the entities, but this sound dirty and cause bad effects.
Has someone used this Lock Modes?
Thanks,
|