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

public Interface EntityDataAccess

extends CachedDomainDataAccess
Known Direct Implementers
org.hibernate.cache.spi.support.AbstractEntityDataAccess, org.hibernate.cache.spi.support.EntityReadWriteAccess
Imports
org.hibernate.cache.CacheException, org.hibernate.engine.spi.SessionFactoryImplementor, .SharedSessionContractImplementor, org.hibernate.persister.entity.EntityPersister

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

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

Authors
Gavin King, Steve Ebersole

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

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

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
,
Object
The item's current version value
currentVersion
,
Object
The item's previous version value
previousVersion
,
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 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?
generateCacheKey
(Object
the primary identifier of the entity
id
,
EntityPersister
Hierarchy for which a key is being generated
rootEntityDescriptor
,
SessionFactoryImplementor
a reference to the current SessionFactory
factory
,
String
the tenant id, or null if multi-tenancy is not being used.
tenantIdentifier
)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
To create instances of keys for this region, Hibernate will invoke this method exclusively so that generated implementations can generate optimised keys.
public Object

Returns:

original id passed to generateCacheKey
getCacheKeyId
(Object
key previously returned from generateCacheKey
cacheKey
)

Performs reverse operation to generateCacheKey

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
,
Object
The item's version value
version
)

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
,
Object
The item's current version value
currentVersion
,
Object
The item's previous version value
previousVersion
)

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

Current session

key:Object

The item key

value:Object

The item

version:Object

The item's version value

Returns:boolean

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

Exceptions
CacheException:
Propagated from underlying cache provider
afterUpdateback to summary
public 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:SharedSessionContractImplementor

Current session

key:Object

The item key

value:Object

The item

currentVersion:Object

The item's current version value

previousVersion:Object

The item's previous version value

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 id, EntityPersister rootEntityDescriptor, SessionFactoryImplementor factory, String tenantIdentifier)

Deprecated

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

To create instances of keys 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 entity

rootEntityDescriptor:EntityPersister

Hierarchy 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 entity on this same region todo (6.0) : the access for an entity knows the entity hierarchy and the factory. why pass them in?

getCacheKeyIdback to summary
public Object getCacheKeyId(Object cacheKey)

Performs reverse operation to generateCacheKey

Parameters
cacheKey:Object

key previously returned from generateCacheKey

Returns:Object

original id passed to generateCacheKey

insertback to summary
public 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:SharedSessionContractImplementor

Current session

key:Object

The item key

value:Object

The item

version:Object

The item's version value

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

Current session

key:Object

The item key

value:Object

The item

currentVersion:Object

The item's current version value

previousVersion:Object

The item's previous version value

Returns:boolean

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

Exceptions
CacheException:
Propagated from underlying cache provider