FileDocCategorySizeDatePackage
IdentityMapAccessor.javaAPI DocGlassfish v2 API20768Tue May 22 16:54:52 BST 2007oracle.toplink.essentials.sessions

IdentityMapAccessor

public interface IdentityMapAccessor
PUBLIC: IdentityMapAccessor provides the public interface into all functionality associated with TopLink identity maps. An appropriate IdentityMapAccessor can be obtained from a session with its getIdentityMapAccessor() method. Methods that used to be called on the Session to access identity maps can now be called through the IdentityMapAccessor.

For instance, to initialize identity maps the code used to be: session.initializeIdentityIdentityMaps()
With this class, the code now is: session.getIdentityMapAccessor().initializeIdentityMaps()

see
oracle.toplink.sessions.Session

Fields Summary
Constructors Summary
Methods Summary
public booleancontainsObjectInIdentityMap(java.lang.Object domainObject)
ADVANCED: Returns true if the identity map contains an Object with the same primary key and Class type of the given domainObject.

param
domainObject Object
return
boolean

public booleancontainsObjectInIdentityMap(java.util.Vector primaryKey, java.lang.Class theClass)
ADVANCED: Returns true if the identity map contains an Object with the same primary key and Class type as those specified.

param
primaryKey Vector
param
theClass Class
return
boolean

public booleancontainsObjectInIdentityMap(oracle.toplink.essentials.sessions.Record rowContainingPrimaryKey, java.lang.Class theClass)
ADVANCED: Returns true if the identity map contains an Object with the same primary key of the specified row (ie. the database record) and Class type.

param
rowContainingPrimaryKey Record
param
theClass Class type to be found
return
boolean - true if Object in indentity map

public java.util.VectorgetAllFromIdentityMap(oracle.toplink.essentials.expressions.Expression selectionCriteria, java.lang.Class theClass, oracle.toplink.essentials.sessions.Record translationRow, oracle.toplink.essentials.queryframework.InMemoryQueryIndirectionPolicy valueHolderPolicy, boolean shouldReturnInvalidatedObjects)
ADVANCED: Queries the cache in-memory with the passed in criteria and returns matching Objects. If the expression is too complex an exception will be thrown. Only returns Objects that are invalid from the map if specified with the boolean shouldReturnInvalidatedObjects.

param
selectionCriteria Expression selecting the Objects to be returned
param
theClass Class to be considered
param
translationRow Record
param
valueHolderPolicy see {@link oracle.toplink.queryframework.InMemoryQueryIndirectionPolicy InMemoryQueryIndirectionPolicy}
param
shouldReturnInvalidatedObjects boolean - true if only invalid Objects should be returned
return
Vector of Objects
throws
QueryException

public java.util.VectorgetAllFromIdentityMap(oracle.toplink.essentials.expressions.Expression selectionCriteria, java.lang.Class theClass, oracle.toplink.essentials.sessions.Record translationRow, oracle.toplink.essentials.queryframework.InMemoryQueryIndirectionPolicy valueHolderPolicy)
ADVANCED: Queries the cache in-memory with the passed in criteria and returns matching Objects. If the expression is too complex an exception will be thrown.

param
selectionCriteria Expression selecting the Objects to be returned
param
theClass Class to be considered
param
translationRow Record
param
valueHolderPolicy see {@link oracle.toplink.queryframework.InMemoryQueryIndirectionPolicy InMemoryQueryIndirectionPolicy}
return
Vector of Objects with type theClass and matching the selectionCriteria
throws
QueryException

public java.lang.ObjectgetFromIdentityMap(oracle.toplink.essentials.sessions.Record rowContainingPrimaryKey, java.lang.Class theClass, boolean shouldReturnInvalidatedObjects)
ADVANCED: Returns the Object from the identity map with the same primary key of the specified row and Class type. May return null and will only Only return an Object that is invalidated if specified with the boolean shouldReturnInvalidatedObjects.

param
rowContainingPrimaryKey Record
param
theClass Class
param
shouldReturnInvalidatedObjects boolean
return
Object from identity map, may be null.

public java.lang.ObjectgetFromIdentityMap(oracle.toplink.essentials.expressions.Expression selectionCriteria, java.lang.Class theClass, oracle.toplink.essentials.sessions.Record translationRow)
ADVANCED: Queries the cache in-memory and returns an Object from this identity map. If the Object is not found with the passed in Class type, Row and selectionCriteria, null is returned. If the expression is too complex an exception will be thrown.

param
selectionCriteria Expression
param
theClass Class
param
translationRow Record
return
Object from identity map, may be null
throws
QueryException

public java.lang.ObjectgetFromIdentityMap(oracle.toplink.essentials.expressions.Expression selectionCriteria, java.lang.Class theClass, oracle.toplink.essentials.sessions.Record translationRow, oracle.toplink.essentials.queryframework.InMemoryQueryIndirectionPolicy valueHolderPolicy)
ADVANCED: Queries the cache in-memory and returns an Object from this identity map. If the Object is not found with the passed in Class type, Row and selectionCriteria, null is returned. This method allows for control of un-instantiated indirection access with valueHolderPolicy. If the expression is too complex an exception will be thrown.

param
selectionCriteria Expression
param
theClass Class
param
translationRow Record
param
valueHolderPolicy see {@link oracle.toplink.queryframework.InMemoryQueryIndirectionPolicy InMemoryQueryIndirectionPolicy}
return
Object from identity map, may be null
throws
QueryException

public java.lang.ObjectgetFromIdentityMap(java.lang.Object domainObject)
ADVANCED: Returns the Object from the identity map with the same primary key and Class type of the given domainObject.

param
domainObject Object
return
Object from identity map, may be null.

public java.lang.ObjectgetFromIdentityMap(java.util.Vector primaryKey, java.lang.Class theClass)
ADVANCED: Returns the Object from the identity map with the same primary key and Class type as those specified.

param
primaryKey Vector
param
theClass Class
return
Object from identity map, may be null.

public java.lang.ObjectgetFromIdentityMap(oracle.toplink.essentials.sessions.Record rowContainingPrimaryKey, java.lang.Class theClass)
ADVANCED: Returns the Object from the identity map with the same primary key of the specified row (ie. the database record) and Class type.

param
rowContainingPrimaryKey Record
param
theClass Class
return
Object from identity map, may be null.

public java.lang.ObjectgetFromIdentityMap(java.util.Vector primaryKey, java.lang.Class theClass, boolean shouldReturnInvalidatedObjects)
ADVANCED: Returns the Object from the identity map with the same primary key and Class type as specified. May return null and will only return an Object that is invalidated if specified with the boolean shouldReturnInvalidatedObjects.

param
primaryKey Vector
param
theClass Class
param
shouldReturnInvalidatedObjects InMemoryQueryIndirectionPolicy
return
Object from identity map, may be null.

public longgetRemainingValidTime(java.lang.Object object)
ADVANCED: Returns the remaining life of the given Object. This method is associated with use of TopLink's cache invalidation feature and returns the difference between the next expiry time of the Object and its read time. The method will return 0 for invalidated Objects.

param
object Object under consideration
return
long time in milliseconds

public java.lang.ObjectgetWriteLockValue(java.lang.Object domainObject)
ADVANCED: Extracts and returns the write lock value from the identity map through the given Object. Write lock values are used when optimistic locking is stored in the cache instead of the object.

param
domainObject Object
return
Object for versioning

public java.lang.ObjectgetWriteLockValue(java.util.Vector primaryKey, java.lang.Class theClass)
ADVANCED: Extracts the write lock value from the identity map through the passed in primaryKey and Class type. Write lock values are used when optimistic locking is stored in the cache instead of the object.

param
primaryKey Vector
param
theClass Class
return
Object for versioning

public voidinitializeAllIdentityMaps()
PUBLIC: Resets the entire Object cache.

NOTE: Be careful using this method. This method blows away both this session's and its parent's 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 Objects held in the cache.

public voidinitializeIdentityMap(java.lang.Class theClass)
PUBLIC: Resets the identity map for only the instances of the given Class type. For inheritance the user must make sure that they only use the root class.

NOTE: 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.

param
theClass Class

public voidinitializeIdentityMaps()
PUBLIC: Resets the entire local Object cache.

NOTE: 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 Objects held in the cache.

public voidinvalidateAll()
ADVANCED: Sets all of the Objects for all classes to be invalid in TopLink's identity maps. It will recurse on inheritance.

public voidinvalidateClass(java.lang.Class myClass)
ADVANCED: Sets all of the Objects of the specified Class type to be invalid in TopLink's identity maps Will set the recurse on inheritance to true.

param
myClass Class

public voidinvalidateClass(java.lang.Class myClass, boolean recurse)
ADVANCED: Sets all of the Objects of the specified Class type to be invalid in TopLink's identity maps. User can set the recurse flag to false if they do not want to invalidate all the same Class types within an inheritance tree.

param
myClass Class
param
recurse boolean

public voidinvalidateObject(java.lang.Object object)
ADVANCED: Sets an Object to be invalid in the TopLink identity maps. If this Object does not exist in the cache, this method will return without any action.

param
object Object

public voidinvalidateObject(java.util.Vector primaryKey, java.lang.Class theClass)
ADVANCED: Sets an Object with the specified primary key and Class type to be invalid in the TopLink identity maps. If the Object does not exist in the cache, this method will return without any action.

param
primaryKey Vector
param
theClass Class

public voidinvalidateObject(oracle.toplink.essentials.sessions.Record rowContainingPrimaryKey, java.lang.Class theClass)
ADVANCED: Sets an Object with the specified primary key of the passed in Row and Class type to be invalid in the TopLink identity maps. If the Object does not exist in the cache, this method will return without any action.

param
rowContainingPrimaryKey Record
param
theClass Class

public voidinvalidateObjects(java.util.Vector collection)
ADVANCED: Sets all of the Objects in the given collection to be invalid in the TopLink identity maps. This method will take no action for any Objects in the collection that do not exist in the cache.

param
collection Vector of Objects to be invalidated

public voidinvalidateObjects(oracle.toplink.essentials.expressions.Expression selectionCriteria)
ADVANCED: Sets all of the Objects matching the given Expression to be invalid in the TopLink identity maps.

Example - Invalidating Employee Objects with non-null first names:

ExpressionBuilder eb = new ExpressionBuilder(Employee.class);
Expression exp = eb.get("firstName").notNull();
session.getIdentityMapAccessor().invalidateObjects(exp);

param
selectionCriteria Expression

public booleanisValid(java.lang.Object object)
ADVANCED: Returns true if an Object with the same primary key and Class type of the the given Object is valid in TopLink's identity maps.

param
object Object
return
boolean

public booleanisValid(java.util.Vector primaryKey, java.lang.Class theClass)
ADVANCED: Returns true if the Object described by the given primary key and Class type is valid in TopLink's identity maps.

param
primaryKey Vector
param
theClass Class
return
boolean

public booleanisValid(oracle.toplink.essentials.internal.sessions.AbstractRecord rowContainingPrimaryKey, java.lang.Class theClass)
ADVANCED: Returns true if this Object with the given primary key of the Row and Class type given is valid in TopLink's identity maps.

param
rowContainingPrimaryKey AbstractRecord
param
theClass Class
return
boolean

public voidprintIdentityMap(java.lang.Class businessClass)
PUBLIC: Used to print all the Objects in the identity map of the given Class type. The output of this method will be logged to this session's SessionLog at SEVERE level.

param
businessClass Class

public voidprintIdentityMapLocks()
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.

public voidprintIdentityMaps()
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.

public java.lang.ObjectputInIdentityMap(java.lang.Object domainObject)
ADVANCED: Registers the given Object with the identity map. The Object must always be registered with its version number if optimistic locking is used.

param
domainObject Object
return
Object

public java.lang.ObjectputInIdentityMap(java.lang.Object domainObject, java.util.Vector key)
ADVANCED: Registers the Object and given key with the identity map. The Object must always be registered with its version number if optimistic locking is used.

param
domainObject Object
param
key Vector
return
Object

public java.lang.ObjectputInIdentityMap(java.lang.Object domainObject, java.util.Vector key, java.lang.Object writeLockValue)
ADVANCED: Registers the Object and given key with the identity map. The Object must always be registered with its version number if optimistic locking is used.

param
domainObject Object
param
key Vector
param
writeLockValue Object for versioning
return
Object

public java.lang.ObjectputInIdentityMap(java.lang.Object domainObject, java.util.Vector key, java.lang.Object writeLockValue, long readTime)
ADVANCED: Registers the given Object with the identity map. 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.

param
domainObject Object
param
key Vector
param
writeLockValue Object for versioning
param
readTime long, time in milliseconds
return
Object the Object put into the identity map

public java.lang.ObjectremoveFromIdentityMap(java.lang.Object domainObject)
ADVANCED: Removes the Object from the Object cache.

NOTE: Caution should be used when calling to avoid violating Object identity. The application should only call this if its known that no references to the Object exist.

param
domainObject Object
return
Object the Object removed from the identity map

public java.lang.ObjectremoveFromIdentityMap(java.util.Vector key, java.lang.Class theClass)
ADVANCED: Removes the Object with given primary key and Class from the Object cache.

NOTE: Caution should be used when calling to avoid violating Object identity. The application should only call this if its known that no references to the Object exist.

param
key Vector
param
theClass Class
return
Object the Object removed from the identity map

public voidupdateWriteLockValue(java.lang.Object domainObject, java.lang.Object writeLockValue)
ADVANCED: Updates the write lock value in the identity map for cache key of the primary key the given Object.

param
domainObject Object
param
writeLockValue Object for versioning

public voidupdateWriteLockValue(java.util.Vector primaryKey, java.lang.Class theClass, java.lang.Object writeLockValue)
ADVANCED: Updates the write lock value in the cache for the Object with same primary key as the given Object. The write lock values is used when optimistic locking is stored in the cache instead of in the object.

param
primaryKey Vector
param
theClass Class
param
writeLockValue Object for versioning

public voidvalidateCache()
ADVANCED: 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 that is not in the cache. This method will validate that all cached Objects are in a correct state.