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

public abstract Class AbstractReadWriteAccess

extends AbstractCachedDomainDataAccess
Class Inheritance
Known Direct Subclasses
org.hibernate.cache.spi.support.CollectionReadWriteAccess, org.hibernate.cache.spi.support.EntityReadWriteAccess, org.hibernate.cache.spi.support.NaturalIdReadWriteAccess
Imports
java.io.Serializable, java.util.Comparator, .Locale, .UUID, java.util.concurrent.atomic.AtomicLong, java.util.concurrent.locks.Lock, .ReentrantReadWriteLock, org.hibernate.cache.spi.DomainDataRegion, .RegionFactory, org.hibernate.cache.spi.access.SoftLock, org.hibernate.engine.spi.SharedSessionContractImplementor, org.jboss.logging.Logger

Author
Steve Ebersole

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
AbstractReadWriteAccess.Item

Wrapper type representing unlocked items.

public static interface
AbstractReadWriteAccess.Lockable

Interface type implemented by all wrapper objects in the cache.

public static class
AbstractReadWriteAccess.SoftLockImpl

Wrapper type representing locked items.

Field Summary

Modifier and TypeField and Description
private static final Logger
private final AtomicLong
private final Lock
private final ReentrantReadWriteLock
private final UUID
private final Lock

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected void
public Object
get(SharedSessionContractImplementor
Current session.
session
,
Object
The key of the item to be retrieved.
key
)

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

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

Returns null if the item is not readable.
protected abstract AccessedDataClassification
protected abstract Comparator<T>
protected void
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.
protected long
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.AbstractCachedDomainDataAccess.putFromLoad.

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

Attempt to cache an object, afterQuery loading from the database.
public final boolean
putFromLoad(SharedSessionContractImplementor
Current session.
session
,
Object
The item key
key
,
Object
The item
value
,
Object
the item version number
version
,
boolean
Explicit minimalPut flag
minimalPutOverride
)

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

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

Attempt to cache an object, afterQuery loading from the database, explicitly specifying the minimalPut behavior.
protected Lock
public void
remove(SharedSessionContractImplementor
Current session.
session
,
Object
The key of the item to remove
key
)

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

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

Called afterQuery an item has become stale (beforeQuery the transaction completes).
public void
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.
protected UUID
uuid()

protected Lock
Inherited from org.hibernate.cache.spi.support.AbstractCachedDomainDataAccess:
clearCachecontainsdestroyevictevictAllgetRegiongetStorageAccesslockRegionunlockRegion

Field Detail

logback to summary
private static final Logger log

Hides org.hibernate.cache.spi.support.AbstractCachedDomainDataAccess.log.

nextLockIdback to summary
private final AtomicLong nextLockId
readLockback to summary
private final Lock readLock
reentrantReadWriteLockback to summary
private final ReentrantReadWriteLock reentrantReadWriteLock
uuidback to summary
private final UUID uuid
writeLockback to summary
private final Lock writeLock

Constructor Detail

AbstractReadWriteAccessback to summary
protected AbstractReadWriteAccess(DomainDataRegion domainDataRegion, DomainDataStorageAccess storageAccess)

Method Detail

decrementLockback to summary
protected void decrementLock(SharedSessionContractImplementor session, Object key, AbstractReadWriteAccess.SoftLockImpl lock)
getback to summary
public Object get(SharedSessionContractImplementor session, Object key)

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

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

Returns null if the item is not readable. Locked items are not readable, nor are items created afterQuery the start of this transaction.

Parameters
session:SharedSessionContractImplementor

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

Current session.

key:Object

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

The key of the item to be retrieved.

Returns:Object

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

the cached data or null

Annotations
@Override
getAccessedDataClassificationback to summary
protected abstract AccessedDataClassification getAccessedDataClassification()
getVersionComparatorback to summary
protected abstract Comparator<T> getVersionComparator()
handleLockExpiryback to summary
protected void handleLockExpiry(SharedSessionContractImplementor session, Object key, AbstractReadWriteAccess.Lockable lock)
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.

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

Overrides org.hibernate.cache.spi.support.AbstractCachedDomainDataAccess.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
putFromLoadback to summary
public final boolean putFromLoad(SharedSessionContractImplementor session, Object key, Object value, Object version, boolean minimalPutOverride)

Overrides org.hibernate.cache.spi.support.AbstractCachedDomainDataAccess.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, explicitly specifying the minimalPut behavior.

Parameters
session:SharedSessionContractImplementor

Current session.

key:Object

The item key

value:Object

The item

version:Object

the item version number

minimalPutOverride:boolean

Explicit minimalPut flag

Returns:boolean

true if the object was successfully cached

Annotations
@Override
readLockback to summary
protected Lock readLock()
removeback to summary
public void remove(SharedSessionContractImplementor session, Object key)

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

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

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

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

Parameters
session:SharedSessionContractImplementor

Current session.

key:Object

The key of the item to remove

Annotations
@Override
removeAllback to summary
public void removeAll(SharedSessionContractImplementor session)

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

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

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

Remove all data for this accessed type

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
uuidback to summary
protected UUID uuid()
writeLockback to summary
protected Lock writeLock()
org.hibernate.cache.spi.support back to summary

public final Class AbstractReadWriteAccess.Item

extends Object
implements Serializable, Lockable
Class Inheritance
All Implemented Interfaces
org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable, java.io.Serializable

Wrapper type representing unlocked items.

Field Summary

Modifier and TypeField and Description
private static final long
private final long
private final Object
private final Object

Constructor Summary

AccessConstructor and Description
pack-priv
Item(Object value, Object version, long timestamp)

Creates an unlocked item wrapping the given value with a version and creation timestamp.

Method Summary

Modifier and TypeMethod and Description
public Object
public boolean
isReadable(long txTimestamp)

Implements org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.isReadable.

Returns true if the enclosed value can be read by a transaction started at the given time.
public boolean
isUnlockable(SoftLock lock)

Implements org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.isUnlockable.

Returns true if the given lock can be unlocked using the given SoftLock instance as a handle.
public boolean
isWriteable(long txTimestamp, Object newVersion, Comparator<T> versionComparator)

Implements org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.isWriteable.

Returns true if the enclosed value can be replaced with one of the given version by a transaction started at the given time.
public AbstractReadWriteAccess.SoftLockImpl
lock(long timeout, UUID uuid, long lockId)

Implements org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.lock.

Locks this entry, stamping it with the UUID and lockId given, with the lock timeout occurring at the specified time.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID
timestampback to summary
private final long timestamp
valueback to summary
private final Object value
versionback to summary
private final Object version

Constructor Detail

Itemback to summary
pack-priv Item(Object value, Object version, long timestamp)

Creates an unlocked item wrapping the given value with a version and creation timestamp.

Method Detail

getValueback to summary
public Object getValue()

Implements org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.getValue.

Doc from org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.getValue.

Returns the enclosed value.

Annotations
@Override
isReadableback to summary
public boolean isReadable(long txTimestamp)

Implements org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.isReadable.

Doc from org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.isReadable.

Returns true if the enclosed value can be read by a transaction started at the given time.

Annotations
@Override
isUnlockableback to summary
public boolean isUnlockable(SoftLock lock)

Implements org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.isUnlockable.

Doc from org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.isUnlockable.

Returns true if the given lock can be unlocked using the given SoftLock instance as a handle.

Annotations
@Override
isWriteableback to summary
public boolean isWriteable(long txTimestamp, Object newVersion, Comparator<T> versionComparator)

Implements org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.isWriteable.

Doc from org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.isWriteable.

Returns true if the enclosed value can be replaced with one of the given version by a transaction started at the given time.

Annotations
@Override
lockback to summary
public AbstractReadWriteAccess.SoftLockImpl lock(long timeout, UUID uuid, long lockId)

Implements org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.lock.

Doc from org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.lock.

Locks this entry, stamping it with the UUID and lockId given, with the lock timeout occurring at the specified time. The returned Lock object can be used to unlock the entry in the future.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.hibernate.cache.spi.support back to summary

public Interface AbstractReadWriteAccess.Lockable

Known Direct Implementers
org.hibernate.cache.spi.support.AbstractReadWriteAccess.Item, org.hibernate.cache.spi.support.AbstractReadWriteAccess.SoftLockImpl

Interface type implemented by all wrapper objects in the cache.

Method Summary

Modifier and TypeMethod and Description
public Object
getValue()

Returns the enclosed value.

public boolean
isReadable(long txTimestamp)

Returns true if the enclosed value can be read by a transaction started at the given time.

public boolean
isUnlockable(SoftLock lock)

Returns true if the given lock can be unlocked using the given SoftLock instance as a handle.

public boolean
isWriteable(long txTimestamp, Object version, Comparator<T> versionComparator)

Returns true if the enclosed value can be replaced with one of the given version by a transaction started at the given time.

public AbstractReadWriteAccess.SoftLockImpl
lock(long timeout, UUID uuid, long lockId)

Locks this entry, stamping it with the UUID and lockId given, with the lock timeout occurring at the specified time.

Method Detail

getValueback to summary
public Object getValue()

Returns the enclosed value.

isReadableback to summary
public boolean isReadable(long txTimestamp)

Returns true if the enclosed value can be read by a transaction started at the given time.

isUnlockableback to summary
public boolean isUnlockable(SoftLock lock)

Returns true if the given lock can be unlocked using the given SoftLock instance as a handle.

isWriteableback to summary
public boolean isWriteable(long txTimestamp, Object version, Comparator<T> versionComparator)

Returns true if the enclosed value can be replaced with one of the given version by a transaction started at the given time.

lockback to summary
public AbstractReadWriteAccess.SoftLockImpl lock(long timeout, UUID uuid, long lockId)

Locks this entry, stamping it with the UUID and lockId given, with the lock timeout occurring at the specified time. The returned Lock object can be used to unlock the entry in the future.

org.hibernate.cache.spi.support back to summary

public Class AbstractReadWriteAccess.SoftLockImpl

extends Object
implements Serializable, Lockable, SoftLock
Class Inheritance
  • java.lang.Object
  • org.hibernate.cache.spi.support.AbstractReadWriteAccess.SoftLockImpl
All Implemented Interfaces
org.hibernate.cache.spi.access.SoftLock, org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable, java.io.Serializable

Wrapper type representing locked items.

Field Summary

Modifier and TypeField and Description
private boolean
private final long
private int
private static final long
private final UUID
private long
private long
private final Object

Constructor Summary

AccessConstructor and Description
pack-priv
SoftLockImpl(long timeout, UUID sourceUuid, long lockId, Object version)

Creates a locked item with the given identifiers and object version.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public Object
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public boolean
isReadable(long txTimestamp)

Implements org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.isReadable.

Returns true if the enclosed value can be read by a transaction started at the given time.
public boolean
isUnlockable(SoftLock lock)

Implements org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.isUnlockable.

Returns true if the given lock can be unlocked using the given SoftLock instance as a handle.
public boolean
isWriteable(long txTimestamp, Object newVersion, Comparator<T> versionComparator)

Implements org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.isWriteable.

Returns true if the enclosed value can be replaced with one of the given version by a transaction started at the given time.
public AbstractReadWriteAccess.SoftLockImpl
lock(long timeout, UUID uuid, long lockId)

Implements org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.lock.

Locks this entry, stamping it with the UUID and lockId given, with the lock timeout occurring at the specified time.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
unlock(long timestamp)

Unlocks this Lock, and timestamps the unlock event.

public boolean
wasLockedConcurrently()

Returns true if this Lock has been concurrently locked by more than one transaction.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

concurrentback to summary
private boolean concurrent
lockIdback to summary
private final long lockId
multiplicityback to summary
private int multiplicity
serialVersionUIDback to summary
private static final long serialVersionUID
sourceUuidback to summary
private final UUID sourceUuid
timeoutback to summary
private long timeout
unlockTimestampback to summary
private long unlockTimestamp
versionback to summary
private final Object version

Constructor Detail

SoftLockImplback to summary
pack-priv SoftLockImpl(long timeout, UUID sourceUuid, long lockId, Object version)

Creates a locked item with the given identifiers and object version.

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getValueback to summary
public Object getValue()

Implements org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.getValue.

Doc from org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.getValue.

Returns the enclosed value.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
isReadableback to summary
public boolean isReadable(long txTimestamp)

Implements org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.isReadable.

Doc from org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.isReadable.

Returns true if the enclosed value can be read by a transaction started at the given time.

Annotations
@Override
isUnlockableback to summary
public boolean isUnlockable(SoftLock lock)

Implements org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.isUnlockable.

Doc from org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.isUnlockable.

Returns true if the given lock can be unlocked using the given SoftLock instance as a handle.

Annotations
@Override
isWriteableback to summary
public boolean isWriteable(long txTimestamp, Object newVersion, Comparator<T> versionComparator)

Implements org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.isWriteable.

Doc from org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.isWriteable.

Returns true if the enclosed value can be replaced with one of the given version by a transaction started at the given time.

Annotations
@Override
lockback to summary
public AbstractReadWriteAccess.SoftLockImpl lock(long timeout, UUID uuid, long lockId)

Implements org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.lock.

Doc from org.hibernate.cache.spi.support.AbstractReadWriteAccess.Lockable.lock.

Locks this entry, stamping it with the UUID and lockId given, with the lock timeout occurring at the specified time. The returned Lock object can be used to unlock the entry in the future.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
unlockback to summary
public void unlock(long timestamp)

Unlocks this Lock, and timestamps the unlock event.

wasLockedConcurrentlyback to summary
public boolean wasLockedConcurrently()

Returns true if this Lock has been concurrently locked by more than one transaction.