Package org.hibernate.cache.spi.access
Interface EntityDataAccess
-
- All Superinterfaces:
CachedDomainDataAccess
- All Known Implementing Classes:
AbstractEntityDataAccess
,EntityNonStrictReadWriteAccess
,EntityReadOnlyAccess
,EntityReadWriteAccess
,EntityTransactionalAccess
public interface EntityDataAccess extends CachedDomainDataAccess
Contract for managing transactional and concurrent access to cached entity data. The expected call sequences related to various operations are:- INSERTS :
insert(org.hibernate.engine.spi.SharedSessionContractImplementor, java.lang.Object, java.lang.Object, java.lang.Object)
thenafterInsert(org.hibernate.engine.spi.SharedSessionContractImplementor, java.lang.Object, java.lang.Object, java.lang.Object)
- UPDATES :
CachedDomainDataAccess.lockItem(org.hibernate.engine.spi.SharedSessionContractImplementor, java.lang.Object, java.lang.Object)
thenupdate(org.hibernate.engine.spi.SharedSessionContractImplementor, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object)
thenafterUpdate(org.hibernate.engine.spi.SharedSessionContractImplementor, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, org.hibernate.cache.spi.access.SoftLock)
- DELETES :
CachedDomainDataAccess.lockItem(org.hibernate.engine.spi.SharedSessionContractImplementor, java.lang.Object, java.lang.Object)
thenCachedDomainDataAccess.remove(org.hibernate.engine.spi.SharedSessionContractImplementor, java.lang.Object)
thenCachedDomainDataAccess.unlockItem(org.hibernate.engine.spi.SharedSessionContractImplementor, java.lang.Object, org.hibernate.cache.spi.access.SoftLock)
- LOADS :
CachedDomainDataAccess.putFromLoad(org.hibernate.engine.spi.SharedSessionContractImplementor, java.lang.Object, java.lang.Object, java.lang.Object)
There is another usage pattern that is used to invalidate entries after performing "bulk" HQL/SQL operations:
CachedDomainDataAccess.lockRegion()
thenCachedDomainDataAccess.removeAll(org.hibernate.engine.spi.SharedSessionContractImplementor)
thenCachedDomainDataAccess.unlockRegion(org.hibernate.cache.spi.access.SoftLock)
-
-
Method Summary
All Methods Instance Methods Abstract 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.Object
getCacheKeyId(Object cacheKey)
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().boolean
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 interface org.hibernate.cache.spi.access.CachedDomainDataAccess
contains, evict, evictAll, get, getAccessType, getRegion, lockItem, lockRegion, putFromLoad, putFromLoad, remove, removeAll, unlockItem, unlockRegion
-
-
-
-
Method Detail
-
generateCacheKey
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.- 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
Object getCacheKeyId(Object cacheKey)
Performs reverse operation togenerateCacheKey(java.lang.Object, org.hibernate.persister.entity.EntityPersister, org.hibernate.engine.spi.SessionFactoryImplementor, java.lang.String)
- Parameters:
cacheKey
- key previously returned fromgenerateCacheKey(java.lang.Object, org.hibernate.persister.entity.EntityPersister, org.hibernate.engine.spi.SessionFactoryImplementor, java.lang.String)
- Returns:
- original id passed to
generateCacheKey(java.lang.Object, org.hibernate.persister.entity.EntityPersister, org.hibernate.engine.spi.SessionFactoryImplementor, java.lang.String)
-
insert
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(). This method is used by "synchronous" concurrency strategies.- 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?
- Throws:
CacheException
- Propagated from underlying cache provider
-
afterInsert
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(). This method is used by "asynchronous" concurrency strategies.- 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?
- Throws:
CacheException
- Propagated from underlying cache provider
-
update
boolean 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(). This method is used by "synchronous" concurrency strategies.- 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?
- Throws:
CacheException
- Propagated from underlying cache provider
-
afterUpdate
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(). This method is used by "asynchronous" concurrency strategies.- 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?
- Throws:
CacheException
- Propagated from underlying cache provider
-
-