Package org.hibernate.cache.spi.support
Class AbstractReadWriteAccess
- java.lang.Object
-
- org.hibernate.cache.spi.support.AbstractCachedDomainDataAccess
-
- org.hibernate.cache.spi.support.AbstractReadWriteAccess
-
- All Implemented Interfaces:
CachedDomainDataAccess,AbstractDomainDataRegion.Destructible
- Direct Known Subclasses:
CollectionReadWriteAccess,EntityReadWriteAccess,NaturalIdReadWriteAccess
public abstract class AbstractReadWriteAccess extends AbstractCachedDomainDataAccess
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractReadWriteAccess.ItemWrapper type representing unlocked items.static interfaceAbstractReadWriteAccess.LockableInterface type implemented by all wrapper objects in the cache.static classAbstractReadWriteAccess.SoftLockImplWrapper type representing locked items.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractReadWriteAccess(DomainDataRegion domainDataRegion, DomainDataStorageAccess storageAccess)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voiddecrementLock(SharedSessionContractImplementor session, java.lang.Object key, AbstractReadWriteAccess.SoftLockImpl lock)java.lang.Objectget(SharedSessionContractImplementor session, java.lang.Object key)Returnsnullif the item is not readable.protected abstract AccessedDataClassificationgetAccessedDataClassification()protected abstract java.util.ComparatorgetVersionComparator()protected voidhandleLockExpiry(SharedSessionContractImplementor session, java.lang.Object key, AbstractReadWriteAccess.Lockable lock)SoftLocklockItem(SharedSessionContractImplementor session, java.lang.Object key, java.lang.Object version)We are going to attempt to update/delete the keyed object.protected longnextLockId()booleanputFromLoad(SharedSessionContractImplementor session, java.lang.Object key, java.lang.Object value, java.lang.Object version)Attempt to cache an object, afterQuery loading from the database.booleanputFromLoad(SharedSessionContractImplementor session, java.lang.Object key, java.lang.Object value, java.lang.Object version, boolean minimalPutOverride)Attempt to cache an object, afterQuery loading from the database, explicitly specifying the minimalPut behavior.protected java.util.concurrent.locks.LockreadLock()voidremove(SharedSessionContractImplementor session, java.lang.Object key)Called afterQuery an item has become stale (beforeQuery the transaction completes).voidremoveAll(SharedSessionContractImplementor session)Remove all data for this accessed typevoidunlockItem(SharedSessionContractImplementor session, java.lang.Object key, SoftLock lock)Called when we have finished the attempted update/delete (which may or may not have been successful), after transaction completion.protected java.util.UUIDuuid()protected java.util.concurrent.locks.LockwriteLock()-
Methods inherited from class org.hibernate.cache.spi.support.AbstractCachedDomainDataAccess
clearCache, contains, destroy, evict, evictAll, getRegion, getStorageAccess, lockRegion, unlockRegion
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.cache.spi.access.CachedDomainDataAccess
getAccessType
-
-
-
-
Constructor Detail
-
AbstractReadWriteAccess
protected AbstractReadWriteAccess(DomainDataRegion domainDataRegion, DomainDataStorageAccess storageAccess)
-
-
Method Detail
-
getVersionComparator
protected abstract java.util.Comparator getVersionComparator()
-
uuid
protected java.util.UUID uuid()
-
nextLockId
protected long nextLockId()
-
readLock
protected java.util.concurrent.locks.Lock readLock()
-
writeLock
protected java.util.concurrent.locks.Lock writeLock()
-
get
public java.lang.Object get(SharedSessionContractImplementor session, java.lang.Object key)
Returnsnullif the item is not readable. Locked items are not readable, nor are items created afterQuery the start of this transaction.- Specified by:
getin interfaceCachedDomainDataAccess- Overrides:
getin classAbstractCachedDomainDataAccess- Parameters:
session- Current session.key- The key of the item to be retrieved.- Returns:
- the cached data or
null
-
putFromLoad
public boolean putFromLoad(SharedSessionContractImplementor session, java.lang.Object key, java.lang.Object value, java.lang.Object version)
Description copied from interface:CachedDomainDataAccessAttempt to cache an object, afterQuery loading from the database.- Specified by:
putFromLoadin interfaceCachedDomainDataAccess- Overrides:
putFromLoadin classAbstractCachedDomainDataAccess- Parameters:
session- Current session.key- The item keyvalue- The itemversion- the item version number- Returns:
trueif the object was successfully cached
-
getAccessedDataClassification
protected abstract AccessedDataClassification getAccessedDataClassification()
-
putFromLoad
public final boolean putFromLoad(SharedSessionContractImplementor session, java.lang.Object key, java.lang.Object value, java.lang.Object version, boolean minimalPutOverride)
Description copied from interface:CachedDomainDataAccessAttempt to cache an object, afterQuery loading from the database, explicitly specifying the minimalPut behavior.- Specified by:
putFromLoadin interfaceCachedDomainDataAccess- Overrides:
putFromLoadin classAbstractCachedDomainDataAccess- Parameters:
session- Current session.key- The item keyvalue- The itemversion- the item version numberminimalPutOverride- Explicit minimalPut flag- Returns:
trueif the object was successfully cached
-
lockItem
public SoftLock lockItem(SharedSessionContractImplementor session, java.lang.Object key, java.lang.Object version)
Description copied from interface:CachedDomainDataAccessWe are going to attempt to update/delete the keyed object. This method is used by "asynchronous" concurrency strategies. The returned object must be passed back toCachedDomainDataAccess.unlockItem(org.hibernate.engine.spi.SharedSessionContractImplementor, java.lang.Object, org.hibernate.cache.spi.access.SoftLock), to release the lock. Concurrency strategies which do not support client-visible locks may silently return null.- Parameters:
session- Current session.key- The key of the item to lockversion- The item's current version value- Returns:
- A representation of our lock on the item; or
null.
-
unlockItem
public void unlockItem(SharedSessionContractImplementor session, java.lang.Object key, SoftLock lock)
Description copied from interface:CachedDomainDataAccessCalled when we have finished the attempted update/delete (which may or may not have been successful), after transaction completion. This method is used by "asynchronous" concurrency strategies.- Parameters:
session- Current session.key- The item keylock- The lock previously obtained fromCachedDomainDataAccess.lockItem(org.hibernate.engine.spi.SharedSessionContractImplementor, java.lang.Object, java.lang.Object)
-
decrementLock
protected void decrementLock(SharedSessionContractImplementor session, java.lang.Object key, AbstractReadWriteAccess.SoftLockImpl lock)
-
handleLockExpiry
protected void handleLockExpiry(SharedSessionContractImplementor session, java.lang.Object key, AbstractReadWriteAccess.Lockable lock)
-
remove
public void remove(SharedSessionContractImplementor session, java.lang.Object key)
Description copied from interface:CachedDomainDataAccessCalled afterQuery an item has become stale (beforeQuery the transaction completes). This method is used by "synchronous" concurrency strategies.- Specified by:
removein interfaceCachedDomainDataAccess- Overrides:
removein classAbstractCachedDomainDataAccess- Parameters:
session- Current session.key- The key of the item to remove
-
removeAll
public void removeAll(SharedSessionContractImplementor session)
Description copied from interface:CachedDomainDataAccessRemove all data for this accessed type- Specified by:
removeAllin interfaceCachedDomainDataAccess- Overrides:
removeAllin classAbstractCachedDomainDataAccess
-
-