Top Description Fields Constructors Methods
org.hibernate.cache.spi.support

public Class CollectionReadWriteAccess

extends AbstractReadWriteAccess
implements CollectionDataAccess
Class Inheritance
All Implemented Interfaces
org.hibernate.cache.spi.access.CollectionDataAccess, org.hibernate.cache.spi.access.CachedDomainDataAccess
Imports
java.util.Comparator, org.hibernate.cache.cfg.spi.CollectionDataCachingConfig, org.hibernate.cache.spi.CacheKeysFactory, .DomainDataRegion, org.hibernate.cache.spi.access.AccessType, .CollectionDataAccess, .SoftLock, org.hibernate.engine.spi.SessionFactoryImplementor, .SharedSessionContractImplementor, org.hibernate.metamodel.model.domain.NavigableRole, org.hibernate.persister.collection.CollectionPersister

Standard support for org.hibernate.cache.spi.access.CollectionDataAccess using the org.hibernate.cache.spi.access.AccessType#READ_WRITE access type.
Authors
Chris Cranford, Steve Ebersole

Field Summary

Modifier and TypeField and Description
private final NavigableRole
private final CacheKeysFactory
private final Comparator<T>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Object
generateCacheKey(Object
the primary identifier of the Collection
id
,
CollectionPersister
the descriptor of the collection for which a key is being generated
collectionDescriptor
,
SessionFactoryImplementor
a reference to the current SessionFactory
factory
,
String
the tenant id, or null if multi-tenancy is not being used.
tenantIdentifier
)

Implements org.hibernate.cache.spi.access.CollectionDataAccess.generateCacheKey.

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
To create instances of CollectionCacheKey for this region, Hibernate will invoke this method exclusively so that generated implementations can generate optimised keys.
public Object
get(SharedSessionContractImplementor
Current session.
session
,
Object
The key of the item to be retrieved.
key
)

Overrides org.hibernate.cache.spi.support.AbstractReadWriteAccess.get.

Implements org.hibernate.cache.spi.access.CachedDomainDataAccess.get.

Attempt to retrieve an object from the cache.
protected AccessedDataClassification
public AccessType
public Object
getCacheKeyId(Object
key previously returned from generateCacheKey
cacheKey
)

Implements org.hibernate.cache.spi.access.CollectionDataAccess.getCacheKeyId.

Performs reverse operation to generateCacheKey
protected Comparator<T>
public SoftLock
lockItem(SharedSessionContractImplementor
Current session.
session
,
Object
The key of the item to lock
key
,
Object
The item's current version value
version
)

Overrides org.hibernate.cache.spi.support.AbstractReadWriteAccess.lockItem.

Implements org.hibernate.cache.spi.access.CachedDomainDataAccess.lockItem.

We are going to attempt to update/delete the keyed object.
public boolean
putFromLoad(SharedSessionContractImplementor
Current session.
session
,
Object
The item key
key
,
Object
The item
value
,
Object
the item version number
version
)

Overrides org.hibernate.cache.spi.support.AbstractReadWriteAccess.putFromLoad.

Implements org.hibernate.cache.spi.access.CachedDomainDataAccess.putFromLoad.

Attempt to cache an object, afterQuery loading from the database.
public void
unlockItem(SharedSessionContractImplementor
Current session.
session
,
Object
The item key
key
,
SoftLock
The lock previously obtained from lockItem
lock
)

Overrides org.hibernate.cache.spi.support.AbstractReadWriteAccess.unlockItem.

Implements org.hibernate.cache.spi.access.CachedDomainDataAccess.unlockItem.

Called when we have finished the attempted update/delete (which may or may not have been successful), after transaction completion.
Inherited from org.hibernate.cache.spi.support.AbstractReadWriteAccess:
decrementLockhandleLockExpirynextLockIdputFromLoadreadLockremoveremoveAlluuidwriteLock

Field Detail

collectionRoleback to summary
private final NavigableRole collectionRole
keysFactoryback to summary
private final CacheKeysFactory keysFactory
versionComparatorback to summary
private final Comparator<T> versionComparator

Constructor Detail

CollectionReadWriteAccessback to summary
public CollectionReadWriteAccess(DomainDataRegion region, CacheKeysFactory keysFactory, DomainDataStorageAccess storageAccess, CollectionDataCachingConfig config)

Method Detail

generateCacheKeyback to summary
public Object generateCacheKey(Object id, CollectionPersister collectionDescriptor, SessionFactoryImplementor factory, String tenantIdentifier)

Implements org.hibernate.cache.spi.access.CollectionDataAccess.generateCacheKey.

Doc from org.hibernate.cache.spi.access.CollectionDataAccess.generateCacheKey.

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

To create instances of CollectionCacheKey for this region, Hibernate will invoke this method exclusively so that generated implementations can generate optimised keys.

Parameters
id:Object

the primary identifier of the Collection

collectionDescriptor:CollectionPersister

the descriptor of the collection for which a key is being generated

factory:SessionFactoryImplementor

a reference to the current SessionFactory

tenantIdentifier:String

the tenant id, or null if multi-tenancy is not being used.

Returns:Object

a key which can be used to identify this collection on this same region

Annotations
@Override
getback to summary
public Object get(SharedSessionContractImplementor session, Object key)

Overrides org.hibernate.cache.spi.support.AbstractReadWriteAccess.get.

Implements org.hibernate.cache.spi.access.CachedDomainDataAccess.get.

Doc from org.hibernate.cache.spi.access.CachedDomainDataAccess.get.

Attempt to retrieve an object from the cache. Mainly used in attempting to resolve entities/collections from the second level cache.

Parameters
session:SharedSessionContractImplementor

Current session.

key:Object

The key of the item to be retrieved.

Returns:Object

the cached data or null

Annotations
@Override
getAccessedDataClassificationback to summary
protected AccessedDataClassification getAccessedDataClassification()

Implements abstract org.hibernate.cache.spi.support.AbstractReadWriteAccess.getAccessedDataClassification.

Annotations
@Override
getAccessTypeback to summary
public AccessType getAccessType()

Implements org.hibernate.cache.spi.access.CachedDomainDataAccess.getAccessType.

Doc from org.hibernate.cache.spi.access.CachedDomainDataAccess.getAccessType.

The type of access implemented

Annotations
@Override
getCacheKeyIdback to summary
public Object getCacheKeyId(Object cacheKey)

Implements org.hibernate.cache.spi.access.CollectionDataAccess.getCacheKeyId.

Doc from org.hibernate.cache.spi.access.CollectionDataAccess.getCacheKeyId.

Performs reverse operation to generateCacheKey

Parameters
cacheKey:Object

key previously returned from generateCacheKey

Returns:Object

original key passed to generateCacheKey

Annotations
@Override
getVersionComparatorback to summary
protected Comparator<T> getVersionComparator()

Implements abstract org.hibernate.cache.spi.support.AbstractReadWriteAccess.getVersionComparator.

Annotations
@Override
lockItemback to summary
public SoftLock lockItem(SharedSessionContractImplementor session, Object key, Object version)

Overrides org.hibernate.cache.spi.support.AbstractReadWriteAccess.lockItem.

Implements org.hibernate.cache.spi.access.CachedDomainDataAccess.lockItem.

Doc from org.hibernate.cache.spi.access.CachedDomainDataAccess.lockItem.

We 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 to unlockItem, to release the lock. Concurrency strategies which do not support client-visible locks may silently return null.

Parameters
session:SharedSessionContractImplementor

Current session.

key:Object

The key of the item to lock

version:Object

The item's current version value

Returns:SoftLock

A representation of our lock on the item; or null.

Annotations
@Override
putFromLoadback to summary
public boolean putFromLoad(SharedSessionContractImplementor session, Object key, Object value, Object version)

Overrides org.hibernate.cache.spi.support.AbstractReadWriteAccess.putFromLoad.

Implements org.hibernate.cache.spi.access.CachedDomainDataAccess.putFromLoad.

Doc from org.hibernate.cache.spi.access.CachedDomainDataAccess.putFromLoad.

Attempt to cache an object, afterQuery loading from the database.

Parameters
session:SharedSessionContractImplementor

Current session.

key:Object

The item key

value:Object

The item

version:Object

the item version number

Returns:boolean

true if the object was successfully cached

Annotations
@Override
unlockItemback to summary
public void unlockItem(SharedSessionContractImplementor session, Object key, SoftLock lock)

Overrides org.hibernate.cache.spi.support.AbstractReadWriteAccess.unlockItem.

Implements org.hibernate.cache.spi.access.CachedDomainDataAccess.unlockItem.

Doc from org.hibernate.cache.spi.access.CachedDomainDataAccess.unlockItem.

Called 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.

Parameters
session:SharedSessionContractImplementor

Current session.

key:Object

The item key

lock:SoftLock

The lock previously obtained from lockItem

Annotations
@Override