Package org.hibernate.cache
Class TransactionalCache
java.lang.Object
org.hibernate.cache.TransactionalCache
- All Implemented Interfaces:
CacheConcurrencyStrategy
Support for fully transactional cache implementations like
JBoss TreeCache. Note that this might be a less scalable
concurrency strategy than ReadWriteCache. This is
a "synchronous" concurrency strategy.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanafterInsert(Object key, Object value, Object version) Do nothing.booleanafterUpdate(Object key, Object value, Object version, SoftLock clientLock) Do nothing.voidclear()Evict all items from the cache immediately.voiddestroy()Clean up all resources.voidCalled after an item has become stale (before the transaction completes).Attempt to retrieve an object from the cache.getCache()Get the wrapped cache implementationGet the cache region namebooleanCalled after an item has been inserted (before the transaction completes), instead of calling evict().Do nothing, returning null.booleanput(Object key, Object value, long txTimestamp, Object version, Comparator versionComparator, boolean minimalPut) Attempt to cache an object, after loading from the database.voidDo nothing.voidEvict an item from the cache immediately (without regard for transaction isolation).voidSet the underlying cache implementation.toString()booleanCalled after an item has been updated (before the transaction completes), instead of calling evict().
-
Constructor Details
-
TransactionalCache
public TransactionalCache()
-
-
Method Details
-
getRegionName
Description copied from interface:CacheConcurrencyStrategyGet the cache region name- Specified by:
getRegionNamein interfaceCacheConcurrencyStrategy
-
get
Description copied from interface:CacheConcurrencyStrategyAttempt to retrieve an object from the cache. Mainly used in attempting to resolve entities/collections from the second level cache.- Specified by:
getin interfaceCacheConcurrencyStrategy- Parameters:
key-txTimestamp- a timestamp prior to the transaction start time- Returns:
- the cached object or null
- Throws:
CacheException
-
put
public boolean put(Object key, Object value, long txTimestamp, Object version, Comparator versionComparator, boolean minimalPut) throws CacheException Description copied from interface:CacheConcurrencyStrategyAttempt to cache an object, after loading from the database.- Specified by:
putin interfaceCacheConcurrencyStrategy- Parameters:
key-value-txTimestamp- a timestamp prior to the transaction start timeversion- the item version numberversionComparator- a comparator used to compare version numbersminimalPut- indicates that the cache should avoid a put is the item is already cached- Returns:
- true if the object was successfully cached
- Throws:
CacheException
-
lock
Do nothing, returning null.- Specified by:
lockin interfaceCacheConcurrencyStrategy- Parameters:
key-version-- Throws:
CacheException
-
release
Do nothing.- Specified by:
releasein interfaceCacheConcurrencyStrategy- Parameters:
key-- Throws:
CacheException
-
update
public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) throws CacheException Description copied from interface:CacheConcurrencyStrategyCalled after an item has been updated (before the transaction completes), instead of calling evict(). This method is used by "synchronous" concurrency strategies.- Specified by:
updatein interfaceCacheConcurrencyStrategy- Throws:
CacheException
-
insert
Description copied from interface:CacheConcurrencyStrategyCalled after an item has been inserted (before the transaction completes), instead of calling evict(). This method is used by "synchronous" concurrency strategies.- Specified by:
insertin interfaceCacheConcurrencyStrategy- Throws:
CacheException
-
evict
Description copied from interface:CacheConcurrencyStrategyCalled after an item has become stale (before the transaction completes). This method is used by "synchronous" concurrency strategies.- Specified by:
evictin interfaceCacheConcurrencyStrategy- Throws:
CacheException
-
remove
Description copied from interface:CacheConcurrencyStrategyEvict an item from the cache immediately (without regard for transaction isolation).- Specified by:
removein interfaceCacheConcurrencyStrategy- Parameters:
key-- Throws:
CacheException
-
clear
Description copied from interface:CacheConcurrencyStrategyEvict all items from the cache immediately.- Specified by:
clearin interfaceCacheConcurrencyStrategy- Throws:
CacheException
-
destroy
public void destroy()Description copied from interface:CacheConcurrencyStrategyClean up all resources.- Specified by:
destroyin interfaceCacheConcurrencyStrategy
-
setCache
Description copied from interface:CacheConcurrencyStrategySet the underlying cache implementation.- Specified by:
setCachein interfaceCacheConcurrencyStrategy- Parameters:
cache-
-
getCache
Description copied from interface:CacheConcurrencyStrategyGet the wrapped cache implementation- Specified by:
getCachein interfaceCacheConcurrencyStrategy
-
afterInsert
Do nothing.- Specified by:
afterInsertin interfaceCacheConcurrencyStrategy- Throws:
CacheException
-
afterUpdate
public boolean afterUpdate(Object key, Object value, Object version, SoftLock clientLock) throws CacheException Do nothing.- Specified by:
afterUpdatein interfaceCacheConcurrencyStrategy- Throws:
CacheException
-
toString
-