Top Description Methods
org.hibernate.cache.spi.access

public Interface NaturalIdDataAccess

extends CachedDomainDataAccess
Known Direct Implementers
org.hibernate.cache.spi.support.AbstractNaturalIdDataAccess, org.hibernate.cache.spi.support.NaturalIdReadWriteAccess
Imports
org.hibernate.cache.CacheException, org.hibernate.engine.spi.SharedSessionContractImplementor, org.hibernate.persister.entity.EntityPersister

Contract for managing transactional and concurrent access to cached naturalId data. The expected call sequences related to various operations are:

Note the special case of UPDATES above. Because the cache key itself has changed here we need to remove the old entry as well

There is another usage pattern that is used to invalidate entries after a query performing "bulk" HQL/SQL operations: lockRegion then removeAll then unlockRegion

IMPORTANT : NaturalIds are not versioned so null will always be passed to the version parameter to:

Authors
Gavin King, Steve Ebersole, Eric Dalquist

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

Were the contents of the cache actually changed by this operation?
afterInsert
(SharedSessionContractImplementor
Current session
session
,
Object
The item key
key
,
Object
The item
value
)

Called afterQuery an item has been inserted (afterQuery the transaction completes), instead of calling release().

public boolean

Returns:

Were the contents of the cache actually changed by this operation?
afterUpdate
(SharedSessionContractImplementor
Current session
session
,
Object
The item key
key
,
Object
The item
value
,
SoftLock
The lock previously obtained from lockItem
lock
)

Called afterQuery an item has been updated (afterQuery the transaction completes), instead of calling release().

public Object

Returns:

a key which can be used to identify an element unequivocally on this same region
generateCacheKey
(Object
the sequence of values which unequivocally identifies a cached element on this region
naturalIdValues
,
EntityPersister
the persister of the element being cached
rootEntityDescriptor
,
SharedSessionContractImplementor session)

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

public Object

Returns:

the sequence of values which unequivocally identifies a cached element on this region
getNaturalIdValues
(Object
key returned from generateCacheKey
cacheKey
)

Performs reverse operation to generateCacheKey, returning the original naturalIdValues.

public boolean

Returns:

Were the contents of the cache actually changed by this operation?
insert
(SharedSessionContractImplementor
Current session
session
,
Object
The item key
key
,
Object
The item
value
)

Called afterQuery an item has been inserted (beforeQuery the transaction completes), instead of calling evict().

public boolean

Returns:

Were the contents of the cache actually changed by this operation?
update
(SharedSessionContractImplementor
Current session
session
,
Object
The item key
key
,
Object
The item
value
)

Called afterQuery an item has been updated (beforeQuery the transaction completes), instead of calling evict().

Inherited from org.hibernate.cache.spi.access.CachedDomainDataAccess:
containsevictevictAllgetgetAccessTypegetRegionlockItemlockRegionputFromLoadputFromLoadremoveremoveAllunlockItemunlockRegion

Method Detail

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

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?

Exceptions
CacheException:
Propagated from underlying cache provider
afterUpdateback to summary
public boolean afterUpdate(SharedSessionContractImplementor session, Object key, Object value, 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: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?

Exceptions
CacheException:
Propagated from underlying cache provider
generateCacheKeyback to summary
public Object generateCacheKey(Object naturalIdValues, EntityPersister rootEntityDescriptor, SharedSessionContractImplementor session)

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

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

getNaturalIdValuesback to summary
public Object getNaturalIdValues(Object cacheKey)

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

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

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?

Exceptions
CacheException:
Propagated from underlying cache provider
updateback to summary
public boolean update(SharedSessionContractImplementor session, Object key, Object value)

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?

Exceptions
CacheException:
Propagated from underlying cache provider