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

public abstract Class AbstractNaturalIdDataAccess

extends AbstractCachedDomainDataAccess
implements NaturalIdDataAccess
Class Inheritance
All Implemented Interfaces
org.hibernate.cache.spi.access.NaturalIdDataAccess, org.hibernate.cache.spi.access.CachedDomainDataAccess
Known Direct Subclasses
org.hibernate.cache.spi.support.NaturalIdNonStrictReadWriteAccess, org.hibernate.cache.spi.support.NaturalIdReadOnlyAccess, org.hibernate.cache.spi.support.NaturalIdTransactionalAccess
Imports
org.hibernate.cache.cfg.spi.NaturalIdDataCachingConfig, org.hibernate.cache.spi.CacheKeysFactory, .DomainDataRegion, org.hibernate.cache.spi.access.NaturalIdDataAccess, .SoftLock, org.hibernate.engine.spi.SharedSessionContractImplementor, org.hibernate.persister.entity.EntityPersister

Author
Steve Ebersole

Field Summary

Modifier and TypeField and Description
private final CacheKeysFactory

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
afterInsert(SharedSessionContractImplementor
Current session
session
,
Object
The item key
key
,
Object
The item
value
)

Implements org.hibernate.cache.spi.access.NaturalIdDataAccess.afterInsert.

Called afterQuery an item has been inserted (afterQuery the transaction completes), instead of calling release().
public boolean
afterUpdate(SharedSessionContractImplementor
Current session
session
,
Object
The item key
key
,
Object
The item
value
,
SoftLock
The lock previously obtained from lockItem
lock
)

Implements org.hibernate.cache.spi.access.NaturalIdDataAccess.afterUpdate.

Called afterQuery an item has been updated (afterQuery the transaction completes), instead of calling release().
public Object
generateCacheKey(Object
the sequence of values which unequivocally identifies a cached element on this region
naturalIdValues
,
EntityPersister
the persister of the element being cached
persister
,
SharedSessionContractImplementor session)

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

To create instances of NaturalIdCacheKey for this region, Hibernate will invoke this method exclusively so that generated implementations can generate optimised keys.
public Object
getNaturalIdValues(Object
key returned from generateCacheKey
cacheKey
)

Implements org.hibernate.cache.spi.access.NaturalIdDataAccess.getNaturalIdValues.

Performs reverse operation to generateCacheKey, returning the original naturalIdValues.
public boolean
insert(SharedSessionContractImplementor
Current session
session
,
Object
The item key
key
,
Object
The item
value
)

Implements org.hibernate.cache.spi.access.NaturalIdDataAccess.insert.

Called afterQuery an item has been inserted (beforeQuery the transaction completes), instead of calling evict().
public SoftLock
lockItem(SharedSessionContractImplementor
Current session.
session
,
Object
The key of the item to lock
key
,
Object
The item's current version value
version
)

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

We are going to attempt to update/delete the keyed object.
public SoftLock
public void
unlockItem(SharedSessionContractImplementor
Current session.
session
,
Object
The item key
key
,
SoftLock
The lock previously obtained from lockItem
lock
)

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.
public void
unlockRegion(SoftLock
The lock previously obtained from lockRegion
lock
)

Overrides org.hibernate.cache.spi.support.AbstractCachedDomainDataAccess.unlockRegion.

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

Called after we have finished the attempted invalidation of the entire region
public boolean
update(SharedSessionContractImplementor
Current session
session
,
Object
The item key
key
,
Object
The item
value
)

Implements org.hibernate.cache.spi.access.NaturalIdDataAccess.update.

Called afterQuery an item has been updated (beforeQuery the transaction completes), instead of calling evict().
Inherited from org.hibernate.cache.spi.support.AbstractCachedDomainDataAccess:
clearCachecontainsdestroyevictevictAllgetgetRegiongetStorageAccessputFromLoadputFromLoadremoveremoveAll

Field Detail

keysFactoryback to summary
private final CacheKeysFactory keysFactory

Constructor Detail

AbstractNaturalIdDataAccessback to summary
public AbstractNaturalIdDataAccess(DomainDataRegion region, CacheKeysFactory keysFactory, DomainDataStorageAccess storageAccess, NaturalIdDataCachingConfig config)

Method Detail

afterInsertback to summary
public boolean afterInsert(SharedSessionContractImplementor session, Object key, Object value)

Implements org.hibernate.cache.spi.access.NaturalIdDataAccess.afterInsert.

Doc from org.hibernate.cache.spi.access.NaturalIdDataAccess.afterInsert.

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:SharedSessionContractImplementor

Current session

key:Object

The item key

value:Object

The item

Returns:boolean

Were the contents of the cache actually changed by this operation?

Annotations
@Override
afterUpdateback to summary
public boolean afterUpdate(SharedSessionContractImplementor session, Object key, Object value, SoftLock lock)

Implements org.hibernate.cache.spi.access.NaturalIdDataAccess.afterUpdate.

Doc from org.hibernate.cache.spi.access.NaturalIdDataAccess.afterUpdate.

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:SharedSessionContractImplementor

Current session

key:Object

The item key

value:Object

The item

lock:SoftLock

The lock previously obtained from lockItem

Returns:boolean

Were the contents of the cache actually changed by this operation?

Annotations
@Override
generateCacheKeyback to summary
public Object generateCacheKey(Object naturalIdValues, EntityPersister persister, SharedSessionContractImplementor session)

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

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

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

Parameters
naturalIdValues:Object

the sequence of values which unequivocally identifies a cached element on this region

persister:EntityPersister

the persister of the element being cached

Returns:Object

a key which can be used to identify an element unequivocally on this same region

Annotations
@Override
getNaturalIdValuesback to summary
public Object getNaturalIdValues(Object cacheKey)

Implements org.hibernate.cache.spi.access.NaturalIdDataAccess.getNaturalIdValues.

Doc from org.hibernate.cache.spi.access.NaturalIdDataAccess.getNaturalIdValues.

Performs reverse operation to generateCacheKey, returning the original naturalIdValues.

Parameters
cacheKey:Object

key returned from generateCacheKey

Returns:Object

the sequence of values which unequivocally identifies a cached element on this region

Annotations
@Override
insertback to summary
public boolean insert(SharedSessionContractImplementor session, Object key, Object value)

Implements org.hibernate.cache.spi.access.NaturalIdDataAccess.insert.

Doc from org.hibernate.cache.spi.access.NaturalIdDataAccess.insert.

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:SharedSessionContractImplementor

Current session

key:Object

The item key

value:Object

The item

Returns:boolean

Were the contents of the cache actually changed by this operation?

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

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.

lockRegionback to summary
public SoftLock lockRegion()

Overrides org.hibernate.cache.spi.support.AbstractCachedDomainDataAccess.lockRegion.

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

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

Lock the entire region

Returns:SoftLock

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

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

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
unlockRegionback to summary
public void unlockRegion(SoftLock lock)

Overrides org.hibernate.cache.spi.support.AbstractCachedDomainDataAccess.unlockRegion.

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

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

Called after we have finished the attempted invalidation of the entire region

Parameters
lock:SoftLock

The lock previously obtained from lockRegion

Annotations
@Override
updateback to summary
public boolean update(SharedSessionContractImplementor session, Object key, Object value)

Implements org.hibernate.cache.spi.access.NaturalIdDataAccess.update.

Doc from org.hibernate.cache.spi.access.NaturalIdDataAccess.update.

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:SharedSessionContractImplementor

Current session

key:Object

The item key

value:Object

The item

Returns:boolean

Were the contents of the cache actually changed by this operation?

Annotations
@Override