Interface CachedDomainDataAccess
-
- All Known Subinterfaces:
CollectionDataAccess
,EntityDataAccess
,NaturalIdDataAccess
- All Known Implementing Classes:
AbstractCachedDomainDataAccess
,AbstractCollectionDataAccess
,AbstractEntityDataAccess
,AbstractNaturalIdDataAccess
,AbstractReadWriteAccess
,CollectionNonStrictReadWriteAccess
,CollectionReadOnlyAccess
,CollectionReadWriteAccess
,CollectionTransactionAccess
,EntityNonStrictReadWriteAccess
,EntityReadOnlyAccess
,EntityReadWriteAccess
,EntityTransactionalAccess
,NaturalIdNonStrictReadWriteAccess
,NaturalIdReadOnlyAccess
,NaturalIdReadWriteAccess
,NaturalIdTransactionalAccess
public interface CachedDomainDataAccess
Base contract for accessing the underlying cached data for a particular Navigable of the user's domain model in a transactionally ACID manner.- API Note:
- Note that the following methods are not considered "transactional"
in this sense:
contains(java.lang.Object)
,lockRegion()
,unlockRegion(org.hibernate.cache.spi.access.SoftLock)
,evict(java.lang.Object)
,evictAll()
. The semantics of these methods come from JPA'sCache
contract. - Implementation Specification:
- The "non-transactional" methods noted in the
@apiNote
should be implemented to ignore any locking. That is, whenevict(java.lang.Object)
is called, the item should be forcibly removed from the cache regardless of whether anything has locked it.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
contains(Object key)
Determine whether this region contains data for the given key.void
evict(Object key)
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.Object
get(SharedSessionContractImplementor session, Object key)
Attempt to retrieve an object from the cache.AccessType
getAccessType()
The type of access implementedDomainDataRegion
getRegion()
The region containing the data being accessedSoftLock
lockItem(SharedSessionContractImplementor session, Object key, Object version)
We are going to attempt to update/delete the keyed object.SoftLock
lockRegion()
Lock 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
removeAll(SharedSessionContractImplementor session)
Remove all data for this accessed typevoid
unlockItem(SharedSessionContractImplementor session, Object key, SoftLock lock)
Called when we have finished the attempted update/delete (which may or may not have been successful), after transaction completion.void
unlockRegion(SoftLock lock)
Called after we have finished the attempted invalidation of the entire region
-
-
-
Method Detail
-
getRegion
DomainDataRegion getRegion()
The region containing the data being accessed
-
getAccessType
AccessType getAccessType()
The type of access implemented
-
get
Object get(SharedSessionContractImplementor session, Object key)
Attempt to retrieve an object from the cache. Mainly used in attempting to resolve entities/collections from the second level cache.- Parameters:
session
- Current session.key
- The key of the item to be retrieved.- Returns:
- the cached data or
null
- Throws:
CacheException
- Propagated from underlying cache provider
-
putFromLoad
boolean putFromLoad(SharedSessionContractImplementor session, Object key, Object value, Object version)
Attempt to cache an object, afterQuery loading from the database.- Parameters:
session
- Current session.key
- The item keyvalue
- The itemversion
- the item version number- Returns:
true
if the object was successfully cached- Throws:
CacheException
- Propagated from underlying cache provider
-
putFromLoad
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.- Parameters:
session
- Current session.key
- The item keyvalue
- The itemversion
- the item version numberminimalPutOverride
- Explicit minimalPut flag- Returns:
true
if the object was successfully cached- Throws:
CacheException
- Propagated from underlying cache provider
-
lockItem
SoftLock lockItem(SharedSessionContractImplementor session, Object key, Object version)
We 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 to
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
. - Throws:
CacheException
- Propagated from underlying cache provider
-
unlockItem
void unlockItem(SharedSessionContractImplementor session, Object key, SoftLock lock)
Called 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 fromlockItem(org.hibernate.engine.spi.SharedSessionContractImplementor, java.lang.Object, java.lang.Object)
- Throws:
CacheException
- Propagated from underlying cache provider
-
remove
void remove(SharedSessionContractImplementor session, Object key)
Called afterQuery an item has become stale (beforeQuery the transaction completes). This method is used by "synchronous" concurrency strategies.- Parameters:
session
- Current session.key
- The key of the item to remove- Throws:
CacheException
- Propagated from underlying cache provider
-
removeAll
void removeAll(SharedSessionContractImplementor session)
Remove all data for this accessed type- Throws:
CacheException
- Propagated from underlying cache provider
-
contains
boolean contains(Object key)
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.
- Parameters:
key
- The cache key- Returns:
- True if the underlying cache contains corresponding data; false otherwise.
-
lockRegion
SoftLock lockRegion()
Lock the entire region- Returns:
- A representation of our lock on the item; or
null
. - Throws:
CacheException
- Propagated from underlying cache provider
-
unlockRegion
void unlockRegion(SoftLock lock)
Called after we have finished the attempted invalidation of the entire region- Parameters:
lock
- The lock previously obtained fromlockRegion()
- Throws:
CacheException
- Propagated from underlying cache provider
-
evict
void evict(Object key)
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)
- Parameters:
key
- The key of the item to remove- Throws:
CacheException
- Propagated from underlying cache provider
-
evictAll
void evictAll()
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()
- Throws:
CacheException
- Propagated from underlying cache provider
-
-