Package org.hibernate.cache.spi.support
Class AbstractEntityDataAccess
- java.lang.Object
-
- org.hibernate.cache.spi.support.AbstractCachedDomainDataAccess
-
- org.hibernate.cache.spi.support.AbstractEntityDataAccess
-
- All Implemented Interfaces:
CachedDomainDataAccess,EntityDataAccess,AbstractDomainDataRegion.Destructible
- Direct Known Subclasses:
EntityNonStrictReadWriteAccess,EntityReadOnlyAccess,EntityTransactionalAccess
public abstract class AbstractEntityDataAccess extends AbstractCachedDomainDataAccess implements EntityDataAccess
-
-
Constructor Summary
Constructors Constructor Description AbstractEntityDataAccess(DomainDataRegion region, CacheKeysFactory cacheKeysFactory, DomainDataStorageAccess storageAccess)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectgenerateCacheKey(java.lang.Object id, EntityPersister rootEntityDescriptor, SessionFactoryImplementor factory, java.lang.String tenantIdentifier)To create instances of keys for this region, Hibernate will invoke this method exclusively so that generated implementations can generate optimised keys.java.lang.ObjectgetCacheKeyId(java.lang.Object cacheKey)SoftLocklockItem(SharedSessionContractImplementor session, java.lang.Object key, java.lang.Object version)We are going to attempt to update/delete the keyed object.SoftLocklockRegion()Lock the entire regionvoidunlockItem(SharedSessionContractImplementor session, java.lang.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-
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
-
Methods inherited from interface org.hibernate.cache.spi.access.EntityDataAccess
afterInsert, afterUpdate, insert, update
-
-
-
-
Constructor Detail
-
AbstractEntityDataAccess
public AbstractEntityDataAccess(DomainDataRegion region, CacheKeysFactory cacheKeysFactory, DomainDataStorageAccess storageAccess)
-
-
Method Detail
-
generateCacheKey
public java.lang.Object generateCacheKey(java.lang.Object id, EntityPersister rootEntityDescriptor, SessionFactoryImplementor factory, java.lang.String tenantIdentifier)Description copied from interface:EntityDataAccessTo create instances of keys for this region, Hibernate will invoke this method exclusively so that generated implementations can generate optimised keys.- Specified by:
generateCacheKeyin 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 java.lang.Object getCacheKeyId(java.lang.Object cacheKey)
Description copied from interface:EntityDataAccessPerforms reverse operation toEntityDataAccess.generateCacheKey(java.lang.Object, org.hibernate.persister.entity.EntityPersister, org.hibernate.engine.spi.SessionFactoryImplementor, java.lang.String)- Specified by:
getCacheKeyIdin 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)
-
lockRegion
public SoftLock lockRegion()
Description copied from interface:CachedDomainDataAccessLock the entire region- Specified by:
lockRegionin interfaceCachedDomainDataAccess- Overrides:
lockRegionin classAbstractCachedDomainDataAccess- Returns:
- A representation of our lock on the item; or
null.
-
unlockRegion
public void unlockRegion(SoftLock lock)
Description copied from interface:CachedDomainDataAccessCalled after we have finished the attempted invalidation of the entire region- Specified by:
unlockRegionin interfaceCachedDomainDataAccess- Overrides:
unlockRegionin classAbstractCachedDomainDataAccess- Parameters:
lock- The lock previously obtained fromCachedDomainDataAccess.lockRegion()
-
lockItem
public SoftLock lockItem(SharedSessionContractImplementor session, java.lang.Object key, java.lang.Object version)
Description copied from interface:CachedDomainDataAccessWe 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 toCachedDomainDataAccess.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:
lockItemin 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, java.lang.Object key, SoftLock lock)
Description copied from interface:CachedDomainDataAccessCalled 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:
unlockItemin 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)
-
-