Package org.hibernate.cache.spi.access
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 cached data for a particular element of
the 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'sCachecontract. - Implementation Specification:
- The "non-transactional" methods noted in the
@apiNoteshould 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
Modifier and TypeMethodDescriptionbooleanDetermine whether this region contains data for the given key.voidForcibly 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.get(SharedSessionContractImplementor session, Object key) Attempt to retrieve an object from the cache.The type of access implementedThe region containing the data being accessedlockItem(SharedSessionContractImplementor session, Object key, Object version) Notify before an attempt to update or delete the keyed object.Lock the entire regionbooleanputFromLoad(SharedSessionContractImplementor session, Object key, Object value, Object version) Attempt to cache an object, after loading it from the database.booleanputFromLoad(SharedSessionContractImplementor session, Object key, Object value, Object version, boolean minimalPutOverride) Attempt to cache an object, after loading from the database, explicitly specifying theminimalPutbehavior.voidremove(SharedSessionContractImplementor session, Object key) Notify that an item has become stale, before completion of the transaction.voidRemove all data for this accessed type.voidunlockItem(SharedSessionContractImplementor session, Object key, SoftLock lock) Notify that an attempt to update or delete the keyed object has completed, with or without success, after transaction completion.voidunlockRegion(SoftLock lock) Called after we have finished the attempted invalidation of the entire region
-
Method Details
-
getRegion
DomainDataRegion getRegion()The region containing the data being accessed -
getAccessType
AccessType getAccessType()The type of access implemented -
contains
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
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
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
-