Package org.hibernate.cache.spi.support
Class EntityReadWriteAccess
- java.lang.Object
-
- org.hibernate.cache.spi.support.AbstractCachedDomainDataAccess
-
- org.hibernate.cache.spi.support.AbstractReadWriteAccess
-
- org.hibernate.cache.spi.support.EntityReadWriteAccess
-
- All Implemented Interfaces:
CachedDomainDataAccess
,EntityDataAccess
,AbstractDomainDataRegion.Destructible
public class EntityReadWriteAccess extends AbstractReadWriteAccess implements EntityDataAccess
Standard support forEntityDataAccess
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 EntityReadWriteAccess(DomainDataRegion domainDataRegion, CacheKeysFactory keysFactory, DomainDataStorageAccess storageAccess, EntityDataCachingConfig entityAccessConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
afterInsert(SharedSessionContractImplementor session, Object key, Object value, Object version)
Called afterQuery an item has been inserted (afterQuery the transaction completes), instead of calling release().boolean
afterUpdate(SharedSessionContractImplementor session, Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock)
Called afterQuery an item has been updated (afterQuery the transaction completes), instead of calling release().Object
generateCacheKey(Object id, EntityPersister rootEntityDescriptor, SessionFactoryImplementor factory, String tenantIdentifier)
To create instances of keys 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
getCacheKeyId(Object cacheKey)
protected Comparator
getVersionComparator()
boolean
insert(SharedSessionContractImplementor session, Object key, Object value, Object version)
Called afterQuery an item has been inserted (beforeQuery the transaction completes), instead of calling evict().SoftLock
lockRegion()
Lock the entire regionboolean
update(SharedSessionContractImplementor session, Object key, Object value, Object currentVersion, Object previousVersion)
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, 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, putFromLoad, putFromLoad, remove, removeAll, unlockItem, unlockRegion
-
-
-
-
Constructor Detail
-
EntityReadWriteAccess
public EntityReadWriteAccess(DomainDataRegion domainDataRegion, CacheKeysFactory keysFactory, DomainDataStorageAccess storageAccess, EntityDataCachingConfig entityAccessConfig)
-
-
Method Detail
-
getAccessType
public AccessType getAccessType()
Description copied from interface:CachedDomainDataAccess
The type of access implemented- Specified by:
getAccessType
in interfaceCachedDomainDataAccess
-
getAccessedDataClassification
protected AccessedDataClassification getAccessedDataClassification()
- Specified by:
getAccessedDataClassification
in classAbstractReadWriteAccess
-
getVersionComparator
protected Comparator getVersionComparator()
- Specified by:
getVersionComparator
in classAbstractReadWriteAccess
-
generateCacheKey
public Object generateCacheKey(Object id, EntityPersister rootEntityDescriptor, SessionFactoryImplementor factory, String tenantIdentifier)
Description copied from interface:EntityDataAccess
To create instances of keys for this region, Hibernate will invoke this method exclusively so that generated implementations can generate optimised keys.- Specified by:
generateCacheKey
in interfaceEntityDataAccess
- Parameters:
id
- the primary identifier of the entityrootEntityDescriptor
- Hierarchy for which a key is being generatedfactory
- a reference to the current SessionFactorytenantIdentifier
- the tenant id, or null if multi-tenancy is not being used.- Returns:
- a key which can be used to identify this entity on this same region todo (6.0) : the access for an entity knows the entity hierarchy and the factory. why pass them in?
-
getCacheKeyId
public Object getCacheKeyId(Object cacheKey)
Description copied from interface:EntityDataAccess
Performs reverse operation toEntityDataAccess.generateCacheKey(java.lang.Object, org.hibernate.persister.entity.EntityPersister, org.hibernate.engine.spi.SessionFactoryImplementor, java.lang.String)
- Specified by:
getCacheKeyId
in interfaceEntityDataAccess
- Parameters:
cacheKey
- key previously returned fromEntityDataAccess.generateCacheKey(java.lang.Object, org.hibernate.persister.entity.EntityPersister, org.hibernate.engine.spi.SessionFactoryImplementor, java.lang.String)
- Returns:
- original id passed to
EntityDataAccess.generateCacheKey(java.lang.Object, org.hibernate.persister.entity.EntityPersister, org.hibernate.engine.spi.SessionFactoryImplementor, java.lang.String)
-
insert
public boolean insert(SharedSessionContractImplementor session, Object key, Object value, Object version)
Description copied from interface:EntityDataAccess
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 interfaceEntityDataAccess
- Parameters:
session
- Current sessionkey
- The item keyvalue
- The itemversion
- The item's version value- Returns:
- Were the contents of the cache actually changed by this operation?
-
afterInsert
public boolean afterInsert(SharedSessionContractImplementor session, Object key, Object value, Object version)
Description copied from interface:EntityDataAccess
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 interfaceEntityDataAccess
- Parameters:
session
- Current sessionkey
- The item keyvalue
- The itemversion
- The item's version value- Returns:
- Were the contents of the cache actual changed by this operation?
-
update
public boolean update(SharedSessionContractImplementor session, Object key, Object value, Object currentVersion, Object previousVersion)
Description copied from interface:EntityDataAccess
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 interfaceEntityDataAccess
- Parameters:
session
- Current sessionkey
- The item keyvalue
- The itemcurrentVersion
- The item's current version valuepreviousVersion
- The item's previous version value- Returns:
- Were the contents of the cache actually changed by this operation?
-
afterUpdate
public boolean afterUpdate(SharedSessionContractImplementor session, Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock)
Description copied from interface:EntityDataAccess
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 interfaceEntityDataAccess
- Parameters:
session
- Current sessionkey
- The item keyvalue
- The itemcurrentVersion
- The item's current version valuepreviousVersion
- The item's previous version valuelock
- 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
.
-
-