Package org.hibernate.cache.access
Interface EntityRegionAccessStrategy
- All Known Implementing Classes:
EntityAccessStrategyAdapter
public interface EntityRegionAccessStrategy
Contract for managing transactional and concurrent access to cached entity
data. The expected call sequences related to various operations are:
- INSERTS :
insert(java.lang.Object, java.lang.Object, java.lang.Object)->afterInsert(java.lang.Object, java.lang.Object, java.lang.Object) - UPDATES :
lockItem(java.lang.Object, java.lang.Object)->update(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object)->afterUpdate(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, org.hibernate.cache.access.SoftLock) - DELETES :
lockItem(java.lang.Object, java.lang.Object)->remove(java.lang.Object)->unlockItem(java.lang.Object, org.hibernate.cache.access.SoftLock)
lockRegion() -> removeAll() -> unlockRegion(org.hibernate.cache.access.SoftLock)-
Method Summary
Modifier and TypeMethodDescriptionbooleanafterInsert(Object key, Object value, Object version) Called after an item has been inserted (after the transaction completes), instead of calling release().booleanCalled after an item has been updated (after the transaction completes), instead of calling release().voidForcibly evict an item from the cache immediately without regard for transaction isolation.voidevictAll()Forcibly evict all items from the cache immediately without regard for transaction isolation.Attempt to retrieve an object from the cache.Get the wrapped entity cache regionbooleanCalled after an item has been inserted (before the transaction completes), instead of calling evict().We are going to attempt to update/delete the keyed object.Lock the entire regionbooleanputFromLoad(Object key, Object value, long txTimestamp, Object version) Attempt to cache an object, after loading from the database.booleanputFromLoad(Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride) Attempt to cache an object, after loading from the database, explicitly specifying the minimalPut behavior.voidCalled after an item has become stale (before the transaction completes).voidCalled to evict data from the entire regionvoidunlockItem(Object key, SoftLock lock) Called when we have finished the attempted update/delete (which may or may not have been successful), after transaction completion.voidunlockRegion(SoftLock lock) Called after we have finished the attempted invalidation of the entire regionbooleanCalled after an item has been updated (before the transaction completes), instead of calling evict().
-
Method Details
-
getRegion
EntityRegion getRegion()Get the wrapped entity cache region- Returns:
- The underlying region
-
get
Attempt to retrieve an object from the cache. Mainly used in attempting to resolve entities/collections from the second level cache.- Parameters:
key- The key of the item to be retrieved.txTimestamp- a timestamp prior to the transaction start time- Returns:
- the cached object or null
- Throws:
CacheException- Propogated from underlyingRegion
-
putFromLoad
boolean putFromLoad(Object key, Object value, long txTimestamp, Object version) throws CacheException Attempt to cache an object, after loading from the database.- Parameters:
key- The item keyvalue- The itemtxTimestamp- a timestamp prior to the transaction start timeversion- the item version number- Returns:
- true if the object was successfully cached
- Throws:
CacheException- Propogated from underlyingRegion
-
putFromLoad
boolean putFromLoad(Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride) throws CacheException Attempt to cache an object, after loading from the database, explicitly specifying the minimalPut behavior.- Parameters:
key- The item keyvalue- The itemtxTimestamp- a timestamp prior to the transaction start timeversion- the item version numberminimalPutOverride- Explicit minimalPut flag- Returns:
- true if the object was successfully cached
- Throws:
CacheException- Propogated from underlyingRegion
-
lockItem
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 release(), to release the lock. Concurrency strategies which do not support client-visible locks may silently return null.- Parameters:
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- Propogated from underlyingRegion
-
lockRegion
Lock the entire region- Returns:
- A representation of our lock on the item; or null.
- Throws:
CacheException- Propogated from underlyingRegion
-
unlockItem
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:
key- The item keylock- The lock previously obtained fromlockItem(java.lang.Object, java.lang.Object)- Throws:
CacheException- Propogated from underlyingRegion
-
unlockRegion
Called after we have finished the attempted invalidation of the entire region- Parameters:
lock- The lock previously obtained fromlockRegion()- Throws:
CacheException- Propogated from underlyingRegion
-
insert
Called after an item has been inserted (before the transaction completes), instead of calling evict(). This method is used by "synchronous" concurrency strategies.- Parameters:
key- The item keyvalue- The itemversion- The item's version value- Returns:
- Were the contents of the cache actual changed by this operation?
- Throws:
CacheException- Propogated from underlyingRegion
-
afterInsert
Called after an item has been inserted (after the transaction completes), instead of calling release(). This method is used by "asynchronous" concurrency strategies.- Parameters:
key- The item keyvalue- The itemversion- The item's version value- Returns:
- Were the contents of the cache actual changed by this operation?
- Throws:
CacheException- Propogated from underlyingRegion
-
update
boolean update(Object key, Object value, Object currentVersion, Object previousVersion) throws CacheException Called after an item has been updated (before the transaction completes), instead of calling evict(). This method is used by "synchronous" concurrency strategies.- Parameters:
key- The item keyvalue- The itemcurrentVersion- The item's current version valuepreviousVersion- The item's previous version value- Returns:
- Were the contents of the cache actual changed by this operation?
- Throws:
CacheException- Propogated from underlyingRegion
-
afterUpdate
boolean afterUpdate(Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock) throws CacheException Called after an item has been updated (after the transaction completes), instead of calling release(). This method is used by "asynchronous" concurrency strategies.- Parameters:
key- The item keyvalue- The itemcurrentVersion- The item's current version valuepreviousVersion- The item's previous version valuelock- The lock previously obtained fromlockItem(java.lang.Object, java.lang.Object)- Returns:
- Were the contents of the cache actual changed by this operation?
- Throws:
CacheException- Propogated from underlyingRegion
-
remove
Called after an item has become stale (before the transaction completes). This method is used by "synchronous" concurrency strategies.- Parameters:
key- The key of the item to remove- Throws:
CacheException- Propogated from underlyingRegion
-
removeAll
Called to evict data from the entire region- Throws:
CacheException- Propogated from underlyingRegion
-
evict
Forcibly evict an item from the cache immediately without regard for transaction isolation.- Parameters:
key- The key of the item to remove- Throws:
CacheException- Propogated from underlyingRegion
-
evictAll
Forcibly evict all items from the cache immediately without regard for transaction isolation.- Throws:
CacheException- Propogated from underlyingRegion
-