Top Description Methods
org.hibernate.cache.access

public Interface CollectionRegionAccessStrategy

Known Direct Implementers
org.hibernate.cache.impl.bridge.CollectionAccessStrategyAdapter
Imports
org.hibernate.cache.CacheException, .CollectionRegion

Contract for managing transactional and concurrent access to cached collection data. For cached collection data, all modification actions actually just invalidate the entry(s). The call sequence here is: lockItem -> remove -> unlockItem

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 void
evict(Object
The key of the item to remove
key
)

Forcibly evict an item from the cache immediately without regard for transaction isolation.

public void
evictAll()

Forcibly evict all items from the cache immediately without regard for transaction isolation.

public Object

Returns:

the cached object or null
get
(Object
The key of the item to be retrieved.
key
,
long
a timestamp prior to the transaction start time
txTimestamp
)

Attempt to retrieve an object from the cache.

public CollectionRegion

Returns:

The underlying region
getRegion
()

Get the wrapped collection cache region

public SoftLock

Returns:

A representation of our lock on the item; or null.
lockItem
(Object
The key of the item to lock
key
,
Object
The item's current version value
version
)

We are going to attempt to update/delete the keyed object.

public SoftLock

Returns:

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

Lock the entire region

public boolean

Returns:

true if the object was successfully cached
putFromLoad
(Object
The item key
key
,
Object
The item
value
,
long
a timestamp prior to the transaction start time
txTimestamp
,
Object
the item version number
version
)

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

public boolean

Returns:

true if the object was successfully cached
putFromLoad
(Object
The item key
key
,
Object
The item
value
,
long
a timestamp prior to the transaction start time
txTimestamp
,
Object
the item version number
version
,
boolean
Explicit minimalPut flag
minimalPutOverride
)

Attempt to cache an object, after loading from the database, explicitly specifying the minimalPut behavior.

public void
remove(Object
The key of the item to remove
key
)

Called after an item has become stale (before the transaction completes).

public void
removeAll()

Called to evict data from the entire region

public void
unlockItem(Object
The item key
key
,
SoftLock
The lock previously obtained from lockItem
lock
)

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
)

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

Method Detail

evictback to summary
public void evict(Object key) throws CacheException

Forcibly evict an item from the cache immediately without regard for transaction isolation.

Parameters
key:Object

The key of the item to remove

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
evictAllback to summary
public void evictAll() throws CacheException

Forcibly evict all items from the cache immediately without regard for transaction isolation.

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
getback to summary
public Object get(Object key, long txTimestamp) throws CacheException

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

Parameters
key:Object

The key of the item to be retrieved.

txTimestamp:long

a timestamp prior to the transaction start time

Returns:Object

the cached object or null

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
getRegionback to summary
public CollectionRegion getRegion()

Get the wrapped collection cache region

Returns:CollectionRegion

The underlying region

lockItemback to summary
public SoftLock lockItem(Object key, Object version) throws CacheException

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

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

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
lockRegionback to summary
public SoftLock lockRegion() throws CacheException

Lock the entire region

Returns:SoftLock

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

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
putFromLoadback to summary
public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version) throws CacheException

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

Parameters
key:Object

The item key

value:Object

The item

txTimestamp:long

a timestamp prior to the transaction start time

version:Object

the item version number

Returns:boolean

true if the object was successfully cached

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
putFromLoadback to summary
public boolean putFromLoad(Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride) throws CacheException

Attempt to cache an object, after loading from the database, explicitly specifying the minimalPut behavior.

Parameters
key:Object

The item key

value:Object

The item

txTimestamp:long

a timestamp prior to the transaction start time

version:Object

the item version number

minimalPutOverride:boolean

Explicit minimalPut flag

Returns:boolean

true if the object was successfully cached

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
removeback to summary
public void remove(Object key) throws CacheException

Called after an item has become stale (before the transaction completes). This method is used by "synchronous" concurrency strategies.

Parameters
key:Object

The key of the item to remove

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
removeAllback to summary
public void removeAll() throws CacheException

Called to evict data from the entire region

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
unlockItemback to summary
public void unlockItem(Object key, SoftLock lock) throws CacheException

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
key:Object

The item key

lock:SoftLock

The lock previously obtained from lockItem

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region
unlockRegionback to summary
public void unlockRegion(SoftLock lock) throws CacheException

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

Parameters
lock:SoftLock

The lock previously obtained from lockRegion

Exceptions
CacheException:
Propogated from underlying org.hibernate.cache.Region