Package org.hibernate.cache.spi.support
Class AbstractCachedDomainDataAccess
- java.lang.Object
-
- org.hibernate.cache.spi.support.AbstractCachedDomainDataAccess
-
- All Implemented Interfaces:
CachedDomainDataAccess,AbstractDomainDataRegion.Destructible
- Direct Known Subclasses:
AbstractCollectionDataAccess,AbstractEntityDataAccess,AbstractNaturalIdDataAccess,AbstractReadWriteAccess
public abstract class AbstractCachedDomainDataAccess extends java.lang.Object implements CachedDomainDataAccess, AbstractDomainDataRegion.Destructible
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractCachedDomainDataAccess(DomainDataRegion region, DomainDataStorageAccess storageAccess)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidclearCache()booleancontains(java.lang.Object key)Determine whether this region contains data for the given key.voiddestroy()voidevict(java.lang.Object key)Forcibly evict an item from the cache immediately without regard for transaction isolation and/or locking.voidevictAll()Forcibly evict all items from the cache immediately without regard for transaction isolation.java.lang.Objectget(SharedSessionContractImplementor session, java.lang.Object key)Attempt to retrieve an object from the cache.DomainDataRegiongetRegion()The region containing the data being accessedprotected DomainDataStorageAccessgetStorageAccess()SoftLocklockRegion()Lock the entire regionbooleanputFromLoad(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.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 typevoidunlockRegion(SoftLock lock)Called after we have finished the attempted invalidation of the entire region-
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, lockItem, unlockItem
-
-
-
-
Constructor Detail
-
AbstractCachedDomainDataAccess
protected AbstractCachedDomainDataAccess(DomainDataRegion region, DomainDataStorageAccess storageAccess)
-
-
Method Detail
-
getRegion
public DomainDataRegion getRegion()
Description copied from interface:CachedDomainDataAccessThe region containing the data being accessed- Specified by:
getRegionin interfaceCachedDomainDataAccess
-
getStorageAccess
protected DomainDataStorageAccess getStorageAccess()
-
clearCache
protected void clearCache()
-
contains
public boolean contains(java.lang.Object key)
Description copied from interface:CachedDomainDataAccessDetermine whether this region contains data for the given key. The semantic here is whether the cache contains data visible for the current call context. This should be viewed as a "best effort", meaning blocking should be avoided if possible.- Specified by:
containsin interfaceCachedDomainDataAccess- Parameters:
key- The cache key- Returns:
- True if the underlying cache contains corresponding data; false otherwise.
-
get
public java.lang.Object get(SharedSessionContractImplementor session, java.lang.Object key)
Description copied from interface:CachedDomainDataAccessAttempt to retrieve an object from the cache. Mainly used in attempting to resolve entities/collections from the second level cache.- Specified by:
getin interfaceCachedDomainDataAccess- 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- Parameters:
session- Current session.key- The item keyvalue- The itemversion- the item version number- Returns:
trueif the object was successfully cached
-
putFromLoad
public 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- Parameters:
session- Current session.key- The item keyvalue- The itemversion- the item version numberminimalPutOverride- Explicit minimalPut flag- Returns:
trueif the object was successfully cached
-
lockRegion
public SoftLock lockRegion()
Description copied from interface:CachedDomainDataAccessLock the entire region- Specified by:
lockRegionin interfaceCachedDomainDataAccess- Returns:
- A representation of our lock on the item; or
null.
-
unlockRegion
public void unlockRegion(SoftLock lock)
Description copied from interface:CachedDomainDataAccessCalled after we have finished the attempted invalidation of the entire region- Specified by:
unlockRegionin interfaceCachedDomainDataAccess- Parameters:
lock- The lock previously obtained fromCachedDomainDataAccess.lockRegion()
-
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- 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
-
evict
public void evict(java.lang.Object key)
Description copied from interface:CachedDomainDataAccessForcibly evict an item from the cache immediately without regard for transaction isolation and/or locking. This behavior is exactly Hibernate legacy behavior, but it is also required by JPA - so we cannot remove it. Used from JPA'sCache.evict(Class, Object), as well as the Hibernate extensionCache.evictEntityData(Class, Serializable)andCache.evictEntityData(String, Serializable)- Specified by:
evictin interfaceCachedDomainDataAccess- Parameters:
key- The key of the item to remove
-
evictAll
public void evictAll()
Description copied from interface:CachedDomainDataAccessForcibly evict all items from the cache immediately without regard for transaction isolation. This behavior is exactly Hibernate legacy behavior, but it is also required by JPA - so we cannot remove it. Used from our JPA impl ofCache.evictAll()as well as the Hibernate extensionsCache.evictEntityData(Class),Cache.evictEntityData(String)andCache.evictEntityData()- Specified by:
evictAllin interfaceCachedDomainDataAccess
-
destroy
public void destroy()
- Specified by:
destroyin interfaceAbstractDomainDataRegion.Destructible
-
-