Package org.hibernate.cache.spi.support
Class AbstractNaturalIdDataAccess
- java.lang.Object
-
- org.hibernate.cache.spi.support.AbstractCachedDomainDataAccess
-
- org.hibernate.cache.spi.support.AbstractNaturalIdDataAccess
-
- All Implemented Interfaces:
CachedDomainDataAccess
,NaturalIdDataAccess
,AbstractDomainDataRegion.Destructible
- Direct Known Subclasses:
NaturalIdNonStrictReadWriteAccess
,NaturalIdReadOnlyAccess
,NaturalIdTransactionalAccess
public abstract class AbstractNaturalIdDataAccess extends AbstractCachedDomainDataAccess implements NaturalIdDataAccess
-
-
Constructor Summary
Constructors Constructor Description AbstractNaturalIdDataAccess(DomainDataRegion region, CacheKeysFactory keysFactory, DomainDataStorageAccess storageAccess, NaturalIdDataCachingConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
afterInsert(SharedSessionContractImplementor session, Object key, Object value)
Called afterQuery an item has been inserted (afterQuery the transaction completes), instead of calling release().boolean
afterUpdate(SharedSessionContractImplementor session, Object key, Object value, SoftLock lock)
Called afterQuery an item has been updated (afterQuery the transaction completes), instead of calling release().Object
generateCacheKey(Object naturalIdValues, EntityPersister persister, SharedSessionContractImplementor session)
To create instances of NaturalIdCacheKey for this region, Hibernate will invoke this method exclusively so that generated implementations can generate optimised keys.Object
getNaturalIdValues(Object cacheKey)
Performs reverse operation toNaturalIdDataAccess.generateCacheKey(java.lang.Object, org.hibernate.persister.entity.EntityPersister, org.hibernate.engine.spi.SharedSessionContractImplementor)
, returning the original naturalIdValues.boolean
insert(SharedSessionContractImplementor session, Object key, Object value)
Called afterQuery an item has been inserted (beforeQuery the transaction completes), instead of calling evict().SoftLock
lockItem(SharedSessionContractImplementor session, Object key, Object version)
We are going to attempt to update/delete the keyed object.SoftLock
lockRegion()
Lock the entire regionvoid
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 regionboolean
update(SharedSessionContractImplementor session, Object key, Object value)
Called afterQuery an item has been updated (beforeQuery the transaction completes), instead of calling evict().-
Methods inherited from class org.hibernate.cache.spi.support.AbstractCachedDomainDataAccess
clearCache, contains, destroy, evict, evictAll, get, getRegion, getStorageAccess, putFromLoad, putFromLoad, remove, removeAll
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.cache.spi.access.CachedDomainDataAccess
contains, evict, evictAll, get, getAccessType, getRegion, putFromLoad, putFromLoad, remove, removeAll
-
-
-
-
Constructor Detail
-
AbstractNaturalIdDataAccess
public AbstractNaturalIdDataAccess(DomainDataRegion region, CacheKeysFactory keysFactory, DomainDataStorageAccess storageAccess, NaturalIdDataCachingConfig config)
-
-
Method Detail
-
generateCacheKey
public Object generateCacheKey(Object naturalIdValues, EntityPersister persister, SharedSessionContractImplementor session)
Description copied from interface:NaturalIdDataAccess
To create instances of NaturalIdCacheKey for this region, Hibernate will invoke this method exclusively so that generated implementations can generate optimised keys.- Specified by:
generateCacheKey
in interfaceNaturalIdDataAccess
- Parameters:
naturalIdValues
- the sequence of values which unequivocally identifies a cached element on this regionpersister
- the persister of the element being cached- Returns:
- a key which can be used to identify an element unequivocally on this same region
-
getNaturalIdValues
public Object getNaturalIdValues(Object cacheKey)
Description copied from interface:NaturalIdDataAccess
Performs reverse operation toNaturalIdDataAccess.generateCacheKey(java.lang.Object, org.hibernate.persister.entity.EntityPersister, org.hibernate.engine.spi.SharedSessionContractImplementor)
, returning the original naturalIdValues.- Specified by:
getNaturalIdValues
in interfaceNaturalIdDataAccess
- Parameters:
cacheKey
- key returned fromNaturalIdDataAccess.generateCacheKey(java.lang.Object, org.hibernate.persister.entity.EntityPersister, org.hibernate.engine.spi.SharedSessionContractImplementor)
- Returns:
- the sequence of values which unequivocally identifies a cached element on this region
-
insert
public boolean insert(SharedSessionContractImplementor session, Object key, Object value)
Description copied from interface:NaturalIdDataAccess
Called afterQuery an item has been inserted (beforeQuery the transaction completes), instead of calling evict(). This method is used by "synchronous" concurrency strategies.- Specified by:
insert
in interfaceNaturalIdDataAccess
- Parameters:
session
- Current sessionkey
- The item keyvalue
- The item- Returns:
- Were the contents of the cache actually changed by this operation?
-
afterInsert
public boolean afterInsert(SharedSessionContractImplementor session, Object key, Object value)
Description copied from interface:NaturalIdDataAccess
Called afterQuery an item has been inserted (afterQuery the transaction completes), instead of calling release(). This method is used by "asynchronous" concurrency strategies.- Specified by:
afterInsert
in interfaceNaturalIdDataAccess
- Parameters:
session
- Current sessionkey
- The item keyvalue
- The item- Returns:
- Were the contents of the cache actually changed by this operation?
-
update
public boolean update(SharedSessionContractImplementor session, Object key, Object value)
Description copied from interface:NaturalIdDataAccess
Called afterQuery an item has been updated (beforeQuery the transaction completes), instead of calling evict(). This method is used by "synchronous" concurrency strategies.- Specified by:
update
in interfaceNaturalIdDataAccess
- Parameters:
session
- Current sessionkey
- The item keyvalue
- The item- Returns:
- Were the contents of the cache actually changed by this operation?
-
afterUpdate
public boolean afterUpdate(SharedSessionContractImplementor session, Object key, Object value, SoftLock lock)
Description copied from interface:NaturalIdDataAccess
Called afterQuery an item has been updated (afterQuery the transaction completes), instead of calling release(). This method is used by "asynchronous" concurrency strategies.- Specified by:
afterUpdate
in interfaceNaturalIdDataAccess
- Parameters:
session
- Current sessionkey
- The item keyvalue
- The itemlock
- The lock previously obtained fromCachedDomainDataAccess.lockItem(org.hibernate.engine.spi.SharedSessionContractImplementor, java.lang.Object, java.lang.Object)
- Returns:
- Were the contents of the cache actually changed by this operation?
-
lockRegion
public SoftLock lockRegion()
Description copied from interface:CachedDomainDataAccess
Lock the entire region- Specified by:
lockRegion
in interfaceCachedDomainDataAccess
- Overrides:
lockRegion
in classAbstractCachedDomainDataAccess
- Returns:
- A representation of our lock on the item; or
null
.
-
unlockRegion
public void unlockRegion(SoftLock lock)
Description copied from interface:CachedDomainDataAccess
Called after we have finished the attempted invalidation of the entire region- Specified by:
unlockRegion
in interfaceCachedDomainDataAccess
- Overrides:
unlockRegion
in classAbstractCachedDomainDataAccess
- Parameters:
lock
- The lock previously obtained fromCachedDomainDataAccess.lockRegion()
-
lockItem
public SoftLock lockItem(SharedSessionContractImplementor session, Object key, Object version)
Description copied from interface:CachedDomainDataAccess
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
CachedDomainDataAccess.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.- Specified by:
lockItem
in interfaceCachedDomainDataAccess
- 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
.
-
unlockItem
public void unlockItem(SharedSessionContractImplementor session, Object key, SoftLock lock)
Description copied from interface:CachedDomainDataAccess
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.- Specified by:
unlockItem
in interfaceCachedDomainDataAccess
- Parameters:
session
- Current session.key
- The item keylock
- The lock previously obtained fromCachedDomainDataAccess.lockItem(org.hibernate.engine.spi.SharedSessionContractImplementor, java.lang.Object, java.lang.Object)
-
-