Package org.hibernate.cache.access
Interface CollectionRegionAccessStrategy
- All Known Implementing Classes:
CollectionAccessStrategyAdapter
public interface CollectionRegionAccessStrategy
Contract for managing transactional and concurrent access to cached collection
data. For cached collection data, all modification actions actually just
invalidate the entry(s). The call sequence here is:
lockItem(java.lang.Object, java.lang.Object) -> remove(java.lang.Object) -> unlockItem(java.lang.Object, org.hibernate.cache.access.SoftLock)
There is another usage pattern that is used to invalidate entries
after performing "bulk" HQL/SQL operations:
lockRegion() -> removeAll() -> unlockRegion(org.hibernate.cache.access.SoftLock)-
Method Summary
Modifier and TypeMethodDescriptionvoidForcibly 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 collection cache regionWe 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 region
-
Method Details
-
getRegion
CollectionRegion getRegion()Get the wrapped collection 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
-
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
-