Module org.eclipse.persistence.core
Class IdentityMapAccessor
java.lang.Object
org.eclipse.persistence.internal.sessions.IdentityMapAccessor
- All Implemented Interfaces:
Serializable
,IdentityMapAccessor
- Direct Known Subclasses:
ClientSessionIdentityMapAccessor
,DistributedSessionIdentityMapAccessor
,IsolatedClientSessionIdentityMapAccessor
,SessionBrokerIdentityMapAccessor
,UnitOfWorkIdentityMapAccessor
INTERNAL:
Internal subclass that provides access to identity maps through the session.
Implements the IdentityMapAccessor interface which provides all publicly available
identity map functionality to users.
This is the main class that should be used to access identity maps. In general, any
function that accesses the identity map manager should go through this class
Any session specific functionality appears in subclasses
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IdentityMapManager
This is the identity map manager for this accessor.protected AbstractSession
-
Constructor Summary
ConstructorsConstructorDescriptionINTERNAL:IdentityMapAccessor
(AbstractSession session) INTERNAL: An IdentityMapAccessor sits between the session and the identityMapManager It needs references in both directions.IdentityMapAccessor
(AbstractSession session, IdentityMapManager identityMapManager) INTERNAL: An IdentityMapAccessor sits between the session and the identityMapManager It needs references in both directions. -
Method Summary
Modifier and TypeMethodDescriptionacquireDeferredLock
(Object primarKey, Class<?> javaClass, ClassDescriptor descriptor, boolean isCacheCheckComplete) INTERNAL: Deferred lock the identity map for the object, this is used for avoiding deadlock The return cacheKey should be used to release the deferred lock.acquireLock
(Object primaryKey, Class<?> domainClass, boolean forMerge, ClassDescriptor descriptor, boolean isCacheCheckComplete) INTERNAL: Provides access for setting a concurrency lock on an object in the IdentityMap.acquireLock
(Object primarKey, Class<?> javaClass, ClassDescriptor descriptor, boolean isCacheCheckComplete) INTERNAL: Lock the identity map for the object, this must be done when building objects.acquireLockNoWait
(Object primaryKey, Class<?> domainClass, boolean forMerge, ClassDescriptor descriptor) INTERNAL: Provides access for setting a concurrency lock on an object in the IdentityMap.acquireLockWithWait
(Object primaryKey, Class<?> domainClass, boolean forMerge, ClassDescriptor descriptor, int wait) INTERNAL: Provides access for setting a concurrency lock on an object in the IdentityMap.acquireReadLockOnCacheKey
(Object primaryKey, Class<?> domainClass, ClassDescriptor descriptor) INTERNAL: Find the cachekey for the provided primary key and place a readlock on it.acquireReadLockOnCacheKeyNoWait
(Object primaryKey, Class<?> domainClass, ClassDescriptor descriptor) INTERNAL: Find the cachekey for the provided primary key and place a readlock on it.boolean
INTERNAL: Lock the entire cache if the cache isolation requires.void
ADVANCED: Clear all the query cachesvoid
clearQueryCache
(String sessionQueryName) ADVANCED: Clear the query cache associated with the named query on the sessionvoid
clearQueryCache
(String descriptorQueryName, Class<?> queryClass) ADVANCED: Clear the query cache associated with the named query on the descriptor for the given classvoid
clearQueryCache
(ReadQuery query) ADVANCED: Clear the query class associated with the passed-in read queryboolean
containsObjectInIdentityMap
(Object object) ADVANCED: Return if their is an object for the primary key.boolean
containsObjectInIdentityMap
(Object primaryKey, Class<?> theClass) ADVANCED: Return if their is an object for the primary key.boolean
containsObjectInIdentityMap
(Object primaryKey, Class<?> theClass, ClassDescriptor descriptor) INTERNAL: Return if their is an object for the primary key.boolean
containsObjectInIdentityMap
(DataRecord rowContainingPrimaryKey, Class<?> theClass) ADVANCED: Return if their is an object for the row containing primary key and the class.protected Object
extractPrimaryKeyFromRow
(DataRecord rowContainingPrimaryKey, Class<?> theClass) INTERNAL: Extract primary key from a row.getAllCacheKeysFromIdentityMapWithEntityPK
(Object[] pkList, ClassDescriptor descriptor) ADVANCED: Using a list of Entity PK this method will attempt to bulk load the entire list from the cache.getAllFromIdentityMap
(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow) ADVANCED: Query the cache in-memory.getAllFromIdentityMap
(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, int valueHolderPolicy) ADVANCED: Query the cache in-memory.getAllFromIdentityMap
(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, int valueHolderPolicy, boolean shouldReturnInvalidatedObjects) ADVANCED: Query the cache in-memory.getAllFromIdentityMap
(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, InMemoryQueryIndirectionPolicy valueHolderPolicy) ADVANCED: Query the cache in-memory.getAllFromIdentityMap
(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, InMemoryQueryIndirectionPolicy valueHolderPolicy, boolean shouldReturnInvalidatedObjects) ADVANCED: Query the cache in-memory.getAllFromIdentityMapWithEntityPK
(Object[] pkList, ClassDescriptor descriptor) ADVANCED: Using a list of Entity PK this method will attempt to bulk load the entire list from the cache.getCacheKeyByIndex
(CacheIndex index, CacheId indexValues, boolean shouldCheckExpiry, ClassDescriptor descriptor) Return the cache key for the cache index or null if not found.getCacheKeyForObject
(Object object) INTERNAL: Retrieve the cache key for the given object.getCacheKeyForObject
(Object primaryKey, Class<?> myClass, ClassDescriptor descriptor, boolean forMerge) INTERNAL: Retrieve the cache key for the given identity information.getCacheKeyForObject
(Object object, ClassDescriptor descriptor) INTERNAL: Retrieve the cache key for the given object from the identity maps.getCacheKeyForObjectForLock
(Object primaryKey, Class<?> myClass, ClassDescriptor descriptor) INTERNAL: Retrieve the cache key for the given identity information.INTERNAL: This method is used to get a list of those classes with IdentityMaps in the Session.getFromIdentityMap
(Object object) ADVANCED: Return the object from the identity with primary and class of the given object.getFromIdentityMap
(Object primaryKey, Class<?> theClass) ADVANCED: Return the object from the identity with the primary and class.getFromIdentityMap
(Object primaryKey, Class<?> theClass, boolean shouldReturnInvalidatedObjects) ADVANCED: Return the object from the identity with the primary and class.getFromIdentityMap
(Object primaryKey, Class<?> theClass, ClassDescriptor descriptor) ADVANCED: Return the object from the identity with the primary and class.getFromIdentityMap
(Object primaryKey, Object object, Class<?> theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) INTERNAL: Return the object from the identity with the primary and class.getFromIdentityMap
(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow) ADVANCED: Query the cache in-memory.getFromIdentityMap
(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, int valueHolderPolicy) ADVANCED: Query the cache in-memory.getFromIdentityMap
(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, int valueHolderPolicy, boolean conforming) INTERNAL: Query the cache in-memory.getFromIdentityMap
(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, int valueHolderPolicy, boolean conforming, boolean shouldReturnInvalidatedObjects) INTERNAL: Query the cache in-memory.getFromIdentityMap
(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, int valueHolderPolicy, boolean conforming, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) INTERNAL: Query the cache in-memory.getFromIdentityMap
(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, InMemoryQueryIndirectionPolicy valueHolderPolicy) ADVANCED: Query the cache in-memory.getFromIdentityMap
(DataRecord rowContainingPrimaryKey, Class<?> theClass) ADVANCED: Return the object from the identity with the primary and class.getFromIdentityMap
(DataRecord rowContainingPrimaryKey, Class<?> theClass, boolean shouldReturnInvalidatedObjects) ADVANCED: Return the object from the identity with the primary and class.getFromIdentityMapWithDeferredLock
(Object primaryKey, Class<?> theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) INTERNAL: Return the object from the identity with the primary and class.getFromIdentityMapWithDeferredLock
(Object primaryKey, Class<?> theClass, ClassDescriptor descriptor) INTERNAL: Return the object from the identity with the primary and class.getFromLocalIdentityMap
(Object primaryKey, Class<?> theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) INTERNAL: Return the object from the local identity map with the primary and class.getFromLocalIdentityMapWithDeferredLock
(Object primaryKey, Class<?> theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) INTERNAL: Return the object from the local identity map with the primary and class.getIdentityMap
(Class<?> theClass) INTERNAL: (public to allow test cases to check) Return the identity map for the class, if missing create a new one.getIdentityMap
(ClassDescriptor descriptor) INTERNAL: Get the identity map for the given class from the IdentityMapManagergetIdentityMap
(ClassDescriptor descriptor, boolean returnNullIfMissing) INTERNAL: Get the identity map for the given class from the IdentityMapManagerINTERNAL: Get the IdentityMapManager for this IdentityMapAccessor This method should be used for all IdentityMapManager access since it may be overridden in sub classes.getQueryResult
(ReadQuery query, List parameters, boolean checkExpiry) INTERNAL: Get the cached results associated with a query.long
getRemainingValidTime
(Object object) ADVANCED: Return the remaining life of this object.INTERNAL: get the session associated with this IdentityMapAccessorgetWrapper
(Object primaryKey, Class<?> theClass) INTERNAL: Get the wrapper object from the cache key associated with the given primary key, this is used for EJB.INTERNAL: Returns the single write Lock manager for this sessiongetWriteLockValue
(Object object) ADVANCED: Extract the write lock value from the identity map.getWriteLockValue
(Object primaryKey, Class<?> theClass) ADVANCED: Extract the write lock value from the identity map.getWriteLockValue
(Object primaryKey, Class<?> theClass, ClassDescriptor descriptor) ADVANCED: Extract the write lock value from the identity map.void
PUBLIC: Reset the entire object cache.void
initializeIdentityMap
(Class<?> theClass) PUBLIC: Reset the identity map for only the instances of the class.void
PUBLIC: Reset the entire local object cache.internalPutInIdentityMap
(Object object, Object key, Object writeLockValue, long readTime, ClassDescriptor descriptor) INTERNAL: Register the object with the cache.void
ADVANCED: Set all of the objects from all identity maps to be invalid in the cache.void
invalidateClass
(Class<?> myClass) ADVANCED: Set all of the objects of a specific class to be invalid in the cache.void
invalidateClass
(Class<?> myClass, boolean recurseAndInvalidateToParentRoot) ADVANCED: Set all of the objects of a specific class to be invalid in the cache.void
invalidateObject
(Object object) ADVANCED: Set an object to be invalid in the cache.void
invalidateObject
(Object object, boolean invalidateCluster) ADVANCED: Set an object to be invalid in the cache.void
invalidateObject
(Object primaryKey, Class<?> theClass) ADVANCED: Set an object to be invalid in the cache.void
invalidateObject
(Object primaryKey, Class<?> theClass, boolean invalidateCluster) ADVANCED: Set an object to be invalid in the cache.void
invalidateObject
(DataRecord rowContainingPrimaryKey, Class<?> theClass) ADVANCED: Set an object to be invalid in the cache.void
invalidateObject
(DataRecord rowContainingPrimaryKey, Class<?> theClass, boolean invalidateCluster) ADVANCED: Set an object to be invalid in the cache.void
invalidateObjects
(Collection collection) ADVANCED: Set all of the objects in the given collection to be invalid in the cache.void
invalidateObjects
(Collection collection, boolean invalidateCluster) ADVANCED: Set all of the objects in the given collection to be invalid in the cache.void
invalidateObjects
(Expression selectionCriteria) ADVANCED: Set all of the objects from the given Expression to be invalid in the cache.void
invalidateObjects
(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, boolean shouldInvalidateOnException) ADVANCED: Queries the cache in-memory with the passed in criteria and invalidates matching Objects.void
invalidateQueryCache
(Class<?> classThatChanged) Invalidate/remove any results for the class from the query cache.boolean
ADVANCED: Return if this object is valid in the cache.boolean
ADVANCED: Return if this object is valid in the cache.boolean
isValid
(DataRecord rowContainingPrimaryKey, Class<?> theClass) ADVANCED: Return if this object is valid in the cache.void
printIdentityMap
(Class<?> businessClass) PUBLIC: Used to print all the objects in the identity map of the passed in class.void
PUBLIC: Used to print all the locks in every identity map in this session.void
PUBLIC: Used to print all the objects in every identity map in this session.void
putCacheKeyByIndex
(CacheIndex index, CacheId indexValues, CacheKey cacheKey, ClassDescriptor descriptor) Index the cache key by the index values.putInIdentityMap
(Object object) ADVANCED: Register the object with the cache.putInIdentityMap
(Object object, Object key) ADVANCED: Register the object with the cache.putInIdentityMap
(Object object, Object key, Object writeLockValue) ADVANCED: Register the object with the cache.putInIdentityMap
(Object object, Object key, Object writeLockValue, long readTime) ADVANCED: Register the object with the cache.putInIdentityMap
(Object object, Object key, Object writeLockValue, long readTime, ClassDescriptor descriptor) ADVANCED: Register the object with the cache.void
putQueryResult
(ReadQuery query, List parameters, Object results) INTERNAL: Set the results for a query.void
INTERNAL: Lock the entire cache if the cache isolation requires.removeFromIdentityMap
(Object object) ADVANCED: Remove the object from the object cache.removeFromIdentityMap
(Object key, Class<?> theClass) ADVANCED: Remove the object from the object cache.removeFromIdentityMap
(Object key, Class<?> theClass, ClassDescriptor descriptor, Object object) INTERNAL: Remove the object from the object cache.void
setIdentityMapManager
(IdentityMapManager identityMapManager) INTERNAL: Set the IdentityMapManager for this IdentityMapAccessorvoid
setWrapper
(Object primaryKey, Class<?> theClass, Object wrapper) INTERNAL: Update the wrapper object the cache key associated with the given primary key, this is used for EJB.void
updateWriteLockValue
(Object primaryKey, Class<?> theClass, Object writeLockValue) ADVANCED: Update the write lock value in the cache.void
updateWriteLockValue
(Object object, Object writeLockValue) ADVANCED: Update the write lock value in the cache.void
INTERNAL: This can be used to help debugging an object identity problem.
-
Field Details
-
identityMapManager
This is the identity map manager for this accessor. It should only be accessed through the getter -
session
-
-
Constructor Details
-
IdentityMapAccessor
public IdentityMapAccessor()INTERNAL: -
IdentityMapAccessor
INTERNAL: An IdentityMapAccessor sits between the session and the identityMapManager It needs references in both directions. -
IdentityMapAccessor
INTERNAL: An IdentityMapAccessor sits between the session and the identityMapManager It needs references in both directions.
-
-
Method Details
-
acquireDeferredLock
public CacheKey acquireDeferredLock(Object primarKey, Class<?> javaClass, ClassDescriptor descriptor, boolean isCacheCheckComplete) INTERNAL: Deferred lock the identity map for the object, this is used for avoiding deadlock The return cacheKey should be used to release the deferred lock. -
acquireLock
public CacheKey acquireLock(Object primarKey, Class<?> javaClass, ClassDescriptor descriptor, boolean isCacheCheckComplete) INTERNAL: Lock the identity map for the object, this must be done when building objects. The return cacheKey should be used to release the lock. -
acquireLock
public CacheKey acquireLock(Object primaryKey, Class<?> domainClass, boolean forMerge, ClassDescriptor descriptor, boolean isCacheCheckComplete) INTERNAL: Provides access for setting a concurrency lock on an object in the IdentityMap. Called with true from the merge process, if true then the refresh will not refresh the object. -
acquireLockNoWait
public CacheKey acquireLockNoWait(Object primaryKey, Class<?> domainClass, boolean forMerge, ClassDescriptor descriptor) INTERNAL: Provides access for setting a concurrency lock on an object in the IdentityMap. Called with true from the merge process, if true then the refresh will not refresh the object. -
acquireLockWithWait
public CacheKey acquireLockWithWait(Object primaryKey, Class<?> domainClass, boolean forMerge, ClassDescriptor descriptor, int wait) INTERNAL: Provides access for setting a concurrency lock on an object in the IdentityMap. Called with true from the merge process, if true then the refresh will not refresh the object. -
acquireReadLockOnCacheKey
public CacheKey acquireReadLockOnCacheKey(Object primaryKey, Class<?> domainClass, ClassDescriptor descriptor) INTERNAL: Find the cachekey for the provided primary key and place a readlock on it. This will allow multiple users to read the same object but prevent writes to the object while the read lock is held. -
acquireReadLockOnCacheKeyNoWait
public CacheKey acquireReadLockOnCacheKeyNoWait(Object primaryKey, Class<?> domainClass, ClassDescriptor descriptor) INTERNAL: Find the cachekey for the provided primary key and place a readlock on it. This will allow multiple users to read the same object but prevent writes to the object while the read lock is held. If no readlock can be acquired then do not wait but return null. -
acquireWriteLock
public boolean acquireWriteLock()INTERNAL: Lock the entire cache if the cache isolation requires. By default concurrent reads and writes are allowed. By write, unit of work merge is meant. -
clearQueryCache
public void clearQueryCache()ADVANCED: Clear all the query caches- Specified by:
clearQueryCache
in interfaceIdentityMapAccessor
-
clearQueryCache
ADVANCED: Clear the query class associated with the passed-in read query- Specified by:
clearQueryCache
in interfaceIdentityMapAccessor
-
clearQueryCache
ADVANCED: Clear the query cache associated with the named query on the session- Specified by:
clearQueryCache
in interfaceIdentityMapAccessor
-
clearQueryCache
ADVANCED: Clear the query cache associated with the named query on the descriptor for the given class- Specified by:
clearQueryCache
in interfaceIdentityMapAccessor
-
containsObjectInIdentityMap
ADVANCED: Return if their is an object for the primary key.- Specified by:
containsObjectInIdentityMap
in interfaceIdentityMapAccessor
-
containsObjectInIdentityMap
ADVANCED: Return if their is an object for the primary key.- Specified by:
containsObjectInIdentityMap
in interfaceIdentityMapAccessor
-
containsObjectInIdentityMap
public boolean containsObjectInIdentityMap(Object primaryKey, Class<?> theClass, ClassDescriptor descriptor) INTERNAL: Return if their is an object for the primary key. -
containsObjectInIdentityMap
ADVANCED: Return if their is an object for the row containing primary key and the class.- Specified by:
containsObjectInIdentityMap
in interfaceIdentityMapAccessor
-
extractPrimaryKeyFromRow
INTERNAL: Extract primary key from a row. -
getCacheKeyForObject
INTERNAL: Retrieve the cache key for the given object from the identity maps.- Parameters:
object
- the object to get the cache key for.
-
getClassesRegistered
INTERNAL: This method is used to get a list of those classes with IdentityMaps in the Session. -
getAllFromIdentityMap
public Vector getAllFromIdentityMap(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow) throws QueryException ADVANCED: Query the cache in-memory. If the expression is too complex an exception will be thrown.- Throws:
QueryException
-
getAllFromIdentityMap
public Vector getAllFromIdentityMap(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, InMemoryQueryIndirectionPolicy valueHolderPolicy) throws QueryException ADVANCED: Query the cache in-memory. If the expression is too complex an exception will be thrown.- Specified by:
getAllFromIdentityMap
in interfaceIdentityMapAccessor
- Parameters:
selectionCriteria
- Expression selecting the Objects to be returnedtheClass
- Class to be consideredtranslationRow
- RecordvalueHolderPolicy
- seeInMemoryQueryIndirectionPolicy
- Returns:
- Vector of Objects with type theClass and matching the selectionCriteria
- Throws:
QueryException
-
getAllFromIdentityMap
public Vector getAllFromIdentityMap(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, int valueHolderPolicy) throws QueryException ADVANCED: Query the cache in-memory. If the expression is too complex an exception will be thrown.- Specified by:
getAllFromIdentityMap
in interfaceIdentityMapAccessor
- Parameters:
selectionCriteria
- Expression selecting the Objects to be returnedtheClass
- Class to be consideredtranslationRow
- RecordvalueHolderPolicy
- seeInMemoryQueryIndirectionPolicy
- Returns:
- Vector of Objects with type theClass and matching the selectionCriteria
- Throws:
QueryException
-
getAllFromIdentityMap
public Vector getAllFromIdentityMap(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, InMemoryQueryIndirectionPolicy valueHolderPolicy, boolean shouldReturnInvalidatedObjects) throws QueryException ADVANCED: Query the cache in-memory. If the expression is too complex an exception will be thrown. Only return objects that are invalid in the cache if specified.- Specified by:
getAllFromIdentityMap
in interfaceIdentityMapAccessor
- Parameters:
selectionCriteria
- Expression selecting the Objects to be returnedtheClass
- Class to be consideredtranslationRow
- RecordvalueHolderPolicy
- seeInMemoryQueryIndirectionPolicy
shouldReturnInvalidatedObjects
- boolean - true if only invalid Objects should be returned- Returns:
- Vector of Objects
- Throws:
QueryException
-
getAllFromIdentityMap
public Vector getAllFromIdentityMap(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, int valueHolderPolicy, boolean shouldReturnInvalidatedObjects) throws QueryException ADVANCED: Query the cache in-memory. If the expression is too complex an exception will be thrown. Only return objects that are invalid in the cache if specified.- Specified by:
getAllFromIdentityMap
in interfaceIdentityMapAccessor
- Parameters:
selectionCriteria
- Expression selecting the Objects to be returnedtheClass
- Class to be consideredtranslationRow
- RecordvalueHolderPolicy
- seeInMemoryQueryIndirectionPolicy
shouldReturnInvalidatedObjects
- boolean - true if only invalid Objects should be returned- Returns:
- Vector of Objects
- Throws:
QueryException
-
getAllFromIdentityMapWithEntityPK
public Map<Object,Object> getAllFromIdentityMapWithEntityPK(Object[] pkList, ClassDescriptor descriptor) ADVANCED: Using a list of Entity PK this method will attempt to bulk load the entire list from the cache. In certain circumstances this can have large performance improvements over loading each item individually.- Parameters:
pkList
- List of Entity PKs to extract from the cachedescriptor
- Descriptor type to be retrieved.- Returns:
- Map of Entity PKs associated to the Entities that were retrieved
-
getAllCacheKeysFromIdentityMapWithEntityPK
public Map<Object,CacheKey> getAllCacheKeysFromIdentityMapWithEntityPK(Object[] pkList, ClassDescriptor descriptor) ADVANCED: Using a list of Entity PK this method will attempt to bulk load the entire list from the cache. In certain circumstances this can have large performance improvements over loading each item individually.- Parameters:
pkList
- List of Entity PKs to extract from the cachedescriptor
- Descriptor type to be retrieved.- Returns:
- Map of Entity PKs associated to the Entities that were retrieved
-
getFromIdentityMap
ADVANCED: Return the object from the identity with primary and class of the given object.- Specified by:
getFromIdentityMap
in interfaceIdentityMapAccessor
- Parameters:
object
- Object- Returns:
- Object from identity map, may be null.
-
getCacheKeyForObject
INTERNAL: Retrieve the cache key for the given object.- Returns:
- CacheKey
-
getCacheKeyForObjectForLock
public CacheKey getCacheKeyForObjectForLock(Object primaryKey, Class<?> myClass, ClassDescriptor descriptor) INTERNAL: Retrieve the cache key for the given identity information.- Parameters:
primaryKey
- the primary key of the cache key to be retrieved.myClass
- the class of the cache key to be retrieved.
-
getCacheKeyForObject
public CacheKey getCacheKeyForObject(Object primaryKey, Class<?> myClass, ClassDescriptor descriptor, boolean forMerge) INTERNAL: Retrieve the cache key for the given identity information.- Parameters:
primaryKey
- the primary key of the cache key to be retrieved.myClass
- the class of the cache key to be retrieved.
-
getFromIdentityMap
ADVANCED: Return the object from the identity with the primary and class.- Specified by:
getFromIdentityMap
in interfaceIdentityMapAccessor
- Returns:
- Object from identity map, may be null.
-
getFromIdentityMap
ADVANCED: Return the object from the identity with the primary and class. -
getFromIdentityMap
public Object getFromIdentityMap(Object primaryKey, Class<?> theClass, boolean shouldReturnInvalidatedObjects) ADVANCED: Return the object from the identity with the primary and class. Only return invalidated objects if requested.- Specified by:
getFromIdentityMap
in interfaceIdentityMapAccessor
- Returns:
- Object from identity map, may be null.
-
getFromIdentityMap
public Object getFromIdentityMap(Object primaryKey, Object object, Class<?> theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) INTERNAL: Return the object from the identity with the primary and class. Only return invalidated objects if requested. -
getFromLocalIdentityMap
public Object getFromLocalIdentityMap(Object primaryKey, Class<?> theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) INTERNAL: Return the object from the local identity map with the primary and class. This avoids checking the parent cache for the unit of work. -
getFromLocalIdentityMapWithDeferredLock
public Object getFromLocalIdentityMapWithDeferredLock(Object primaryKey, Class<?> theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) INTERNAL: Return the object from the local identity map with the primary and class. This avoids checking the parent cache for the unit of work. -
getFromIdentityMap
ADVANCED: Return the object from the identity with the primary and class.- Specified by:
getFromIdentityMap
in interfaceIdentityMapAccessor
- Parameters:
rowContainingPrimaryKey
- RecordtheClass
- Class- Returns:
- Object from identity map, may be null.
-
getFromIdentityMap
public Object getFromIdentityMap(DataRecord rowContainingPrimaryKey, Class<?> theClass, boolean shouldReturnInvalidatedObjects) ADVANCED: Return the object from the identity with the primary and class. Only return invalidated objects if requested.- Specified by:
getFromIdentityMap
in interfaceIdentityMapAccessor
- Parameters:
rowContainingPrimaryKey
- RecordtheClass
- ClassshouldReturnInvalidatedObjects
- boolean- Returns:
- Object from identity map, may be null.
-
getFromIdentityMap
public Object getFromIdentityMap(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow) throws QueryException ADVANCED: Query the cache in-memory. If the object is not found null is returned. If the expression is too complex an exception will be thrown.- Specified by:
getFromIdentityMap
in interfaceIdentityMapAccessor
- Parameters:
selectionCriteria
- ExpressiontheClass
- ClasstranslationRow
- Record- Returns:
- Object from identity map, may be null
- Throws:
QueryException
-
getFromIdentityMap
public Object getFromIdentityMap(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, InMemoryQueryIndirectionPolicy valueHolderPolicy) throws QueryException ADVANCED: Query the cache in-memory. If the object is not found null is returned. If the expression is too complex an exception will be thrown.- Specified by:
getFromIdentityMap
in interfaceIdentityMapAccessor
- Parameters:
selectionCriteria
- ExpressiontheClass
- ClasstranslationRow
- RecordvalueHolderPolicy
- seeInMemoryQueryIndirectionPolicy
- Returns:
- Object from identity map, may be null
- Throws:
QueryException
-
getFromIdentityMap
public Object getFromIdentityMap(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, int valueHolderPolicy) throws QueryException ADVANCED: Query the cache in-memory. If the object is not found null is returned. If the expression is too complex an exception will be thrown.- Specified by:
getFromIdentityMap
in interfaceIdentityMapAccessor
- Parameters:
selectionCriteria
- ExpressiontheClass
- ClasstranslationRow
- RecordvalueHolderPolicy
- seeInMemoryQueryIndirectionPolicy
- Returns:
- Object from identity map, may be null
- Throws:
QueryException
-
getFromIdentityMap
public Object getFromIdentityMap(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, int valueHolderPolicy, boolean conforming) INTERNAL: Query the cache in-memory. If the object is not found null is returned. If the expression is too complex an exception will be thrown. -
getFromIdentityMap
public Object getFromIdentityMap(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, int valueHolderPolicy, boolean conforming, boolean shouldReturnInvalidatedObjects) INTERNAL: Query the cache in-memory. If the object is not found null is returned. If the expression is too complex an exception will be thrown. -
getFromIdentityMap
public Object getFromIdentityMap(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, int valueHolderPolicy, boolean conforming, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) INTERNAL: Query the cache in-memory. If the object is not found null is returned. If the expression is too complex an exception will be thrown. -
getFromIdentityMapWithDeferredLock
public Object getFromIdentityMapWithDeferredLock(Object primaryKey, Class<?> theClass, ClassDescriptor descriptor) INTERNAL: Return the object from the identity with the primary and class. -
getFromIdentityMapWithDeferredLock
public Object getFromIdentityMapWithDeferredLock(Object primaryKey, Class<?> theClass, boolean shouldReturnInvalidatedObjects, ClassDescriptor descriptor) INTERNAL: Return the object from the identity with the primary and class. Only return invalidated objects if requested -
getIdentityMapManager
INTERNAL: Get the IdentityMapManager for this IdentityMapAccessor This method should be used for all IdentityMapManager access since it may be overridden in sub classes. -
getIdentityMap
INTERNAL: (public to allow test cases to check) Return the identity map for the class, if missing create a new one. -
getIdentityMap
INTERNAL: Get the identity map for the given class from the IdentityMapManager -
getIdentityMap
INTERNAL: Get the identity map for the given class from the IdentityMapManager -
getQueryResult
INTERNAL: Get the cached results associated with a query. Results are cached by the values of the parameters to the query so different parameters will have different cached results. -
getRemainingValidTime
ADVANCED: Return the remaining life of this object. This method is associated with use of cache invalidation and returns the difference between the next expiry time of the object and its read time. The method will return 0 for invalidated objects.- Specified by:
getRemainingValidTime
in interfaceIdentityMapAccessor
- Parameters:
object
- Object under consideration- Returns:
- long time in milliseconds
-
getSession
INTERNAL: get the session associated with this IdentityMapAccessor -
getWrapper
INTERNAL: Get the wrapper object from the cache key associated with the given primary key, this is used for EJB. -
getWriteLockManager
INTERNAL: Returns the single write Lock manager for this session -
getWriteLockValue
ADVANCED: Extract the write lock value from the identity map.- Specified by:
getWriteLockValue
in interfaceIdentityMapAccessor
- Parameters:
object
- Object- Returns:
- Object for versioning
-
getWriteLockValue
ADVANCED: Extract the write lock value from the identity map.- Specified by:
getWriteLockValue
in interfaceIdentityMapAccessor
-
getWriteLockValue
ADVANCED: Extract the write lock value from the identity map. -
initializeAllIdentityMaps
public void initializeAllIdentityMaps()PUBLIC: Reset the entire object cache.NOTE: be careful using this method. This method blows away both this session's and its parents caches, this includes the server cache or any other cache. This throws away any objects that have been read in. Extreme caution should be used before doing this because object identity will no longer be maintained for any objects currently read in. This should only be called if the application knows that it no longer has references to object held in the cache.
- Specified by:
initializeAllIdentityMaps
in interfaceIdentityMapAccessor
-
initializeIdentityMap
PUBLIC: Reset the identity map for only the instances of the class. For inheritance the user must make sure that they only use the root class. Caution must be used in doing this to ensure that the objects within the identity map are not referenced from other objects of other classes or from the application.- Specified by:
initializeIdentityMap
in interfaceIdentityMapAccessor
- Parameters:
theClass
- Class
-
initializeIdentityMaps
public void initializeIdentityMaps()PUBLIC: Reset the entire local object cache. This throws away any objects that have been read in. Extreme caution should be used before doing this because object identity will no longer be maintained for any objects currently read in. This should only be called if the application knows that it no longer has references to object held in the cache.- Specified by:
initializeIdentityMaps
in interfaceIdentityMapAccessor
-
invalidateObject
ADVANCED: Set an object to be invalid in the cache. If the object does not exist in the cache, this method will return without any action.- Specified by:
invalidateObject
in interfaceIdentityMapAccessor
- Parameters:
object
- Object
-
invalidateObject
ADVANCED: Set an object to be invalid in the cache.- Specified by:
invalidateObject
in interfaceIdentityMapAccessor
- Parameters:
invalidateCluster
- if true the invalidation will be broadcast to each server in the cluster.
-
invalidateObject
ADVANCED: Set an object to be invalid in the cache. If the object does not exist in the cache, this method will return without any action.- Specified by:
invalidateObject
in interfaceIdentityMapAccessor
-
invalidateObject
ADVANCED: Set an object to be invalid in the cache.- Specified by:
invalidateObject
in interfaceIdentityMapAccessor
- Parameters:
invalidateCluster
- if true the invalidation will be broadcast to each server in the cluster.
-
invalidateObject
ADVANCED: Set an object to be invalid in the cache. If the object does not exist in the cache, this method will return without any action.- Specified by:
invalidateObject
in interfaceIdentityMapAccessor
-
invalidateObject
public void invalidateObject(DataRecord rowContainingPrimaryKey, Class<?> theClass, boolean invalidateCluster) ADVANCED: Set an object to be invalid in the cache.- Specified by:
invalidateObject
in interfaceIdentityMapAccessor
- Parameters:
invalidateCluster
- if true the invalidation will be broadcast to each server in the cluster.
-
invalidateObjects
ADVANCED: Set all of the objects from the given Expression to be invalid in the cache.- Specified by:
invalidateObjects
in interfaceIdentityMapAccessor
- Parameters:
selectionCriteria
- Expression
-
invalidateObjects
public void invalidateObjects(Expression selectionCriteria, Class<?> theClass, DataRecord translationRow, boolean shouldInvalidateOnException) ADVANCED: Queries the cache in-memory with the passed in criteria and invalidates matching Objects. If the expression is too complex either all or none object of theClass invalidated (depending on shouldInvalidateOnException value).- Specified by:
invalidateObjects
in interfaceIdentityMapAccessor
- Parameters:
selectionCriteria
- Expression selecting the Objects to be returnedtheClass
- Class to be consideredtranslationRow
- RecordshouldInvalidateOnException
- boolean indicates weather to invalidate the object if conform threw exception.
-
invalidateObjects
ADVANCED: Set all of the objects in the given collection to be invalid in the cache. This method will take no action for any objects in the collection that do not exist in the cache.- Specified by:
invalidateObjects
in interfaceIdentityMapAccessor
- Parameters:
collection
- objects to be invalidated
-
invalidateObjects
ADVANCED: Set all of the objects in the given collection to be invalid in the cache.- Specified by:
invalidateObjects
in interfaceIdentityMapAccessor
- Parameters:
invalidateCluster
- if true the invalidation will be broadcast to each server in the cluster.
-
invalidateClass
ADVANCED: Set all of the objects of a specific class to be invalid in the cache. Will set the recurseAndInvalidateToParentRoot flag on inheritance to true.- Specified by:
invalidateClass
in interfaceIdentityMapAccessor
-
invalidateClass
ADVANCED: Set all of the objects of a specific class to be invalid in the cache. User can set the recurse flag to false if they do not want to invalidate all the classes within an inheritance tree and instead invalidate the subtree rooted at myClass.- Specified by:
invalidateClass
in interfaceIdentityMapAccessor
- Parameters:
myClass
- - the class where we start invalidationrecurseAndInvalidateToParentRoot
- - default is true where we invalidate up the inheritance tree to the root descriptor
-
invalidateQueryCache
Invalidate/remove any results for the class from the query cache. This is used to invalidate the query cache on any change.- Specified by:
invalidateQueryCache
in interfaceIdentityMapAccessor
-
invalidateAll
public void invalidateAll()ADVANCED: Set all of the objects from all identity maps to be invalid in the cache.- Specified by:
invalidateAll
in interfaceIdentityMapAccessor
-
isValid
ADVANCED: Return if this object is valid in the cache.- Specified by:
isValid
in interfaceIdentityMapAccessor
-
isValid
ADVANCED: Return if this object is valid in the cache.- Specified by:
isValid
in interfaceIdentityMapAccessor
-
isValid
ADVANCED: Return if this object is valid in the cache.- Specified by:
isValid
in interfaceIdentityMapAccessor
-
printIdentityMap
PUBLIC: Used to print all the objects in the identity map of the passed in class. The output of this method will be logged to this session's SessionLog at SEVERE level.- Specified by:
printIdentityMap
in interfaceIdentityMapAccessor
-
printIdentityMaps
public void printIdentityMaps()PUBLIC: Used to print all the objects in every identity map in this session. The output of this method will be logged to this session's SessionLog at SEVERE level.- Specified by:
printIdentityMaps
in interfaceIdentityMapAccessor
-
printIdentityMapLocks
public void printIdentityMapLocks()PUBLIC: Used to print all the locks in every identity map in this session. The output of this method will be logged to this session's SessionLog at FINEST level.- Specified by:
printIdentityMapLocks
in interfaceIdentityMapAccessor
-
putInIdentityMap
ADVANCED: Register the object with the cache. The object must always be registered with its version number if optimistic locking is used.- Specified by:
putInIdentityMap
in interfaceIdentityMapAccessor
- Parameters:
object
- Object- Returns:
- Object
-
putInIdentityMap
ADVANCED: Register the object with the cache. The object must always be registered with its version number if optimistic locking is used.- Specified by:
putInIdentityMap
in interfaceIdentityMapAccessor
-
putInIdentityMap
ADVANCED: Register the object with the cache. The object must always be registered with its version number if optimistic locking is used.- Specified by:
putInIdentityMap
in interfaceIdentityMapAccessor
-
putInIdentityMap
ADVANCED: Register the object with the cache. The object must always be registered with its version number if optimistic locking is used. The readTime may also be included in the cache key as it is constructed.- Specified by:
putInIdentityMap
in interfaceIdentityMapAccessor
- Parameters:
object
- Objectkey
- ObjectwriteLockValue
- Object for versioningreadTime
- long, time in milliseconds- Returns:
- Object the Object put into the identity map
-
putInIdentityMap
public Object putInIdentityMap(Object object, Object key, Object writeLockValue, long readTime, ClassDescriptor descriptor) ADVANCED: Register the object with the cache. The object must always be registered with its version number if optimistic locking is used. The readTime may also be included in the cache key as it is constructed. -
putQueryResult
INTERNAL: Set the results for a query. Query results are cached based on the parameter values provided to the query different parameter values access different caches. -
putCacheKeyByIndex
public void putCacheKeyByIndex(CacheIndex index, CacheId indexValues, CacheKey cacheKey, ClassDescriptor descriptor) Index the cache key by the index values. -
getCacheKeyByIndex
public CacheKey getCacheKeyByIndex(CacheIndex index, CacheId indexValues, boolean shouldCheckExpiry, ClassDescriptor descriptor) Return the cache key for the cache index or null if not found. -
internalPutInIdentityMap
public CacheKey internalPutInIdentityMap(Object object, Object key, Object writeLockValue, long readTime, ClassDescriptor descriptor) INTERNAL: Register the object with the cache. The object must always be registered with its version number if optimistic locking is used. The readTime may also be included in the cache key as it is constructed. Return the cache-key. -
releaseWriteLock
public void releaseWriteLock()INTERNAL: Lock the entire cache if the cache isolation requires. By default concurrent reads and writes are allowed. By write, unit of work merge is meant. -
removeFromIdentityMap
ADVANCED: Remove the object from the object cache. Caution should be used when calling to avoid violating object identity. The application should only call this is it knows that no references to the object exist.- Specified by:
removeFromIdentityMap
in interfaceIdentityMapAccessor
- Parameters:
object
- Object- Returns:
- Object the Object removed from the identity map
-
removeFromIdentityMap
ADVANCED: Remove the object from the object cache.- Specified by:
removeFromIdentityMap
in interfaceIdentityMapAccessor
- Returns:
- Object the Object removed from the identity map
-
removeFromIdentityMap
public Object removeFromIdentityMap(Object key, Class<?> theClass, ClassDescriptor descriptor, Object object) INTERNAL: Remove the object from the object cache. -
setIdentityMapManager
INTERNAL: Set the IdentityMapManager for this IdentityMapAccessor -
setWrapper
INTERNAL: Update the wrapper object the cache key associated with the given primary key, this is used for EJB. -
updateWriteLockValue
ADVANCED: Update the write lock value in the cache.- Specified by:
updateWriteLockValue
in interfaceIdentityMapAccessor
- Parameters:
object
- ObjectwriteLockValue
- Object for versioning
-
updateWriteLockValue
ADVANCED: Update the write lock value in the cache.- Specified by:
updateWriteLockValue
in interfaceIdentityMapAccessor
-
validateCache
public void validateCache()INTERNAL: This can be used to help debugging an object identity problem. An object identity problem is when an object in the cache references an object not in the cache. This method will validate that all cached objects are in a correct state.- Specified by:
validateCache
in interfaceIdentityMapAccessor
-