I'm trying to figure out whether, or how, I can get Hibernate to acquire an UPGRADE, or WRITE, lock on an entity cached in a transactional 2nd-level cache such as JBoss TreeCache, when I use Session.get or Session.load.
Digging inside the code it seems that, by default, Hibernate effectively ignores all LockMode values when the 2-level cache strategy in affect is TRANSACTIONAL (no lock is acquired either in the database or the cache).
Some transactional cache implementations such as IBM eXtreme Scale product do support a getForUpdate() operation which acquires an UPGRADE lock.
One option might be to override the default EntityPersister to use my own implementation of TransactionalCache.
|