Package org.hibernate.cache.spi.support
Class NaturalIdReadWriteAccess
- java.lang.Object
-
- org.hibernate.cache.spi.support.AbstractCachedDomainDataAccess
-
- org.hibernate.cache.spi.support.AbstractReadWriteAccess
-
- org.hibernate.cache.spi.support.NaturalIdReadWriteAccess
-
- All Implemented Interfaces:
CachedDomainDataAccess
,NaturalIdDataAccess
,AbstractDomainDataRegion.Destructible
public class NaturalIdReadWriteAccess extends AbstractReadWriteAccess implements NaturalIdDataAccess
Standard support forNaturalIdDataAccess
using theAccessType.READ_WRITE
access type.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.hibernate.cache.spi.support.AbstractReadWriteAccess
AbstractReadWriteAccess.Item, AbstractReadWriteAccess.Lockable, AbstractReadWriteAccess.SoftLockImpl
-
-
Constructor Summary
Constructors Constructor Description NaturalIdReadWriteAccess(DomainDataRegion region, CacheKeysFactory keysFactory, DomainDataStorageAccess storageAccess, NaturalIdDataCachingConfig naturalIdDataCachingConfig)
-
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 rootEntityDescriptor, SharedSessionContractImplementor session)
To create instances of NaturalIdCacheKey for this region, Hibernate will invoke this method exclusively so that generated implementations can generate optimised keys.protected AccessedDataClassification
getAccessedDataClassification()
AccessType
getAccessType()
The type of access implementedObject
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.protected Comparator
getVersionComparator()
boolean
insert(SharedSessionContractImplementor session, Object key, Object value)
Called afterQuery an item has been inserted (beforeQuery the transaction completes), instead of calling evict().boolean
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.AbstractReadWriteAccess
decrementLock, get, handleLockExpiry, lockItem, nextLockId, putFromLoad, putFromLoad, readLock, remove, removeAll, unlockItem, uuid, writeLock
-
Methods inherited from class org.hibernate.cache.spi.support.AbstractCachedDomainDataAccess
clearCache, contains, destroy, evict, evictAll, getRegion, getStorageAccess, lockRegion, unlockRegion
-
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, getRegion, lockItem, lockRegion, putFromLoad, putFromLoad, remove, removeAll, unlockItem, unlockRegion
-
-
-
-
Constructor Detail
-
NaturalIdReadWriteAccess
public NaturalIdReadWriteAccess(DomainDataRegion region, CacheKeysFactory keysFactory, DomainDataStorageAccess storageAccess, NaturalIdDataCachingConfig naturalIdDataCachingConfig)
-
-
Method Detail
-
getAccessedDataClassification
protected AccessedDataClassification getAccessedDataClassification()
- Specified by:
getAccessedDataClassification
in classAbstractReadWriteAccess
-
getAccessType
public AccessType getAccessType()
Description copied from interface:CachedDomainDataAccess
The type of access implemented- Specified by:
getAccessType
in interfaceCachedDomainDataAccess
-
getVersionComparator
protected Comparator getVersionComparator()
- Specified by:
getVersionComparator
in classAbstractReadWriteAccess
-
generateCacheKey
public Object generateCacheKey(Object naturalIdValues, EntityPersister rootEntityDescriptor, 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 regionrootEntityDescriptor
- 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?
-
-