Package org.hibernate.cache.spi.support
Class CollectionReadWriteAccess
- java.lang.Object
-
- org.hibernate.cache.spi.support.AbstractCachedDomainDataAccess
-
- org.hibernate.cache.spi.support.AbstractReadWriteAccess
-
- org.hibernate.cache.spi.support.CollectionReadWriteAccess
-
- All Implemented Interfaces:
CachedDomainDataAccess,CollectionDataAccess,AbstractDomainDataRegion.Destructible
public class CollectionReadWriteAccess extends AbstractReadWriteAccess implements CollectionDataAccess
Standard support forCollectionDataAccessusing theAccessType.READ_WRITEaccess 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 CollectionReadWriteAccess(DomainDataRegion region, CacheKeysFactory keysFactory, DomainDataStorageAccess storageAccess, CollectionDataCachingConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectgenerateCacheKey(java.lang.Object id, CollectionPersister collectionDescriptor, SessionFactoryImplementor factory, java.lang.String tenantIdentifier)To create instances of CollectionCacheKey for this region, Hibernate will invoke this method exclusively so that generated implementations can generate optimised keys.java.lang.Objectget(SharedSessionContractImplementor session, java.lang.Object key)Returnsnullif the item is not readable.protected AccessedDataClassificationgetAccessedDataClassification()AccessTypegetAccessType()The type of access implementedjava.lang.ObjectgetCacheKeyId(java.lang.Object cacheKey)protected java.util.ComparatorgetVersionComparator()SoftLocklockItem(SharedSessionContractImplementor session, java.lang.Object key, java.lang.Object version)We are going to attempt to update/delete the keyed object.booleanputFromLoad(SharedSessionContractImplementor session, java.lang.Object key, java.lang.Object value, java.lang.Object version)Attempt to cache an object, afterQuery loading from the database.voidunlockItem(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.-
Methods inherited from class org.hibernate.cache.spi.support.AbstractReadWriteAccess
decrementLock, handleLockExpiry, nextLockId, putFromLoad, readLock, remove, removeAll, 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, getRegion, lockRegion, putFromLoad, remove, removeAll, unlockRegion
-
-
-
-
Constructor Detail
-
CollectionReadWriteAccess
public CollectionReadWriteAccess(DomainDataRegion region, CacheKeysFactory keysFactory, DomainDataStorageAccess storageAccess, CollectionDataCachingConfig config)
-
-
Method Detail
-
getAccessedDataClassification
protected AccessedDataClassification getAccessedDataClassification()
- Specified by:
getAccessedDataClassificationin classAbstractReadWriteAccess
-
getAccessType
public AccessType getAccessType()
Description copied from interface:CachedDomainDataAccessThe type of access implemented- Specified by:
getAccessTypein interfaceCachedDomainDataAccess
-
generateCacheKey
public java.lang.Object generateCacheKey(java.lang.Object id, CollectionPersister collectionDescriptor, SessionFactoryImplementor factory, java.lang.String tenantIdentifier)Description copied from interface:CollectionDataAccessTo create instances of CollectionCacheKey for this region, Hibernate will invoke this method exclusively so that generated implementations can generate optimised keys.- Specified by:
generateCacheKeyin interfaceCollectionDataAccess- Parameters:
id- the primary identifier of the CollectioncollectionDescriptor- the descriptor of the collection 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 collection on this same region
-
getCacheKeyId
public java.lang.Object getCacheKeyId(java.lang.Object cacheKey)
Description copied from interface:CollectionDataAccessPerforms reverse operation toCollectionDataAccess.generateCacheKey(java.lang.Object, org.hibernate.persister.collection.CollectionPersister, org.hibernate.engine.spi.SessionFactoryImplementor, java.lang.String)- Specified by:
getCacheKeyIdin interfaceCollectionDataAccess- Parameters:
cacheKey- key previously returned fromCollectionDataAccess.generateCacheKey(java.lang.Object, org.hibernate.persister.collection.CollectionPersister, org.hibernate.engine.spi.SessionFactoryImplementor, java.lang.String)- Returns:
- original key passed to
CollectionDataAccess.generateCacheKey(java.lang.Object, org.hibernate.persister.collection.CollectionPersister, org.hibernate.engine.spi.SessionFactoryImplementor, java.lang.String)
-
getVersionComparator
protected java.util.Comparator getVersionComparator()
- Specified by:
getVersionComparatorin classAbstractReadWriteAccess
-
get
public java.lang.Object get(SharedSessionContractImplementor session, java.lang.Object key)
Description copied from class:AbstractReadWriteAccessReturnsnullif the item is not readable. Locked items are not readable, nor are items created afterQuery the start of this transaction.- Specified by:
getin interfaceCachedDomainDataAccess- Overrides:
getin classAbstractReadWriteAccess- Parameters:
session- Current session.key- The key of the item to be retrieved.- Returns:
- the cached data or
null
-
putFromLoad
public boolean putFromLoad(SharedSessionContractImplementor session, java.lang.Object key, java.lang.Object value, java.lang.Object version)
Description copied from interface:CachedDomainDataAccessAttempt to cache an object, afterQuery loading from the database.- Specified by:
putFromLoadin interfaceCachedDomainDataAccess- Overrides:
putFromLoadin classAbstractReadWriteAccess- Parameters:
session- Current session.key- The item keyvalue- The itemversion- the item version number- Returns:
trueif the object was successfully cached
-
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- Overrides:
lockItemin classAbstractReadWriteAccess- 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- Overrides:
unlockItemin classAbstractReadWriteAccess- 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)
-
-