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 Object
implements CachedDomainDataAccess, AbstractDomainDataRegion.Destructible
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractCachedDomainDataAccess
(DomainDataRegion region, DomainDataStorageAccess storageAccess) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
boolean
Determine whether this region contains data for the given key.void
destroy()
void
Forcibly evict an item from the cache immediately without regard for transaction isolation and/or locking.void
evictAll()
Forcibly evict all items from the cache immediately without regard for transaction isolation.get
(SharedSessionContractImplementor session, Object key) Attempt to retrieve an object from the cache.The region containing the data being accessedLock the entire regionboolean
putFromLoad
(SharedSessionContractImplementor session, Object key, Object value, Object version) Attempt to cache an object, afterQuery loading from the database.boolean
putFromLoad
(SharedSessionContractImplementor session, Object key, Object value, Object version, boolean minimalPutOverride) Attempt to cache an object, afterQuery loading from the database, explicitly specifying the minimalPut behavior.void
remove
(SharedSessionContractImplementor session, Object key) Called afterQuery an item has become stale (beforeQuery the transaction completes).void
Remove all data for this accessed typevoid
unlockRegion
(SoftLock lock) Called after we have finished the attempted invalidation of the entire regionMethods 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 Details
-
AbstractCachedDomainDataAccess
protected AbstractCachedDomainDataAccess(DomainDataRegion region, DomainDataStorageAccess storageAccess)
-
-
Method Details
-
getRegion
Description copied from interface:CachedDomainDataAccess
The region containing the data being accessed- Specified by:
getRegion
in interfaceCachedDomainDataAccess
-
getStorageAccess
-
clearCache
protected void clearCache() -
contains
Description copied from interface:CachedDomainDataAccess
Determine 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:
contains
in interfaceCachedDomainDataAccess
- Parameters:
key
- The cache key- Returns:
- True if the underlying cache contains corresponding data; false otherwise.
-
lockRegion
Description copied from interface:CachedDomainDataAccess
Lock the entire region- Specified by:
lockRegion
in interfaceCachedDomainDataAccess
- Returns:
- A representation of our lock on the item; or
null
.
-
unlockRegion
Description copied from interface:CachedDomainDataAccess
Called after we have finished the attempted invalidation of the entire region- Specified by:
unlockRegion
in interfaceCachedDomainDataAccess
- Parameters:
lock
- The lock previously obtained fromCachedDomainDataAccess.lockRegion()
-
evict
Description copied from interface:CachedDomainDataAccess
Forcibly 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's
Cache.evict(Class, Object)
, as well as the Hibernate extensionCache.evictEntityData(Class, Object)
andCache.evictEntityData(String, Object)
- Specified by:
evict
in interfaceCachedDomainDataAccess
- Parameters:
key
- The key of the item to remove
-
evictAll
public void evictAll()Description copied from interface:CachedDomainDataAccess
Forcibly 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 of
Cache.evictAll()
as well as the Hibernate extensionsCache.evictEntityData(Class)
,Cache.evictEntityData(String)
andCache.evictEntityData()
- Specified by:
evictAll
in interfaceCachedDomainDataAccess
-
destroy
public void destroy()- Specified by:
destroy
in interfaceAbstractDomainDataRegion.Destructible
-