Top Description Fields Constructors Methods
org.eclipse.persistence.descriptors

public Class CachePolicy

extends Object
implements Cloneable, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Cloneable
Imports
java.io.Serializable, java.util.HashMap, .HashSet, .List, .Map, .Set, org.eclipse.persistence.annotations.CacheCoordinationType, .CacheKeyType, .DatabaseChangeNotificationType, org.eclipse.persistence.config.CacheIsolationType, org.eclipse.persistence.exceptions.DescriptorException, .ValidationException, org.eclipse.persistence.expressions.Expression, org.eclipse.persistence.internal.helper.ClassConstants, .DatabaseField, org.eclipse.persistence.internal.identitymaps.CacheId, .CacheKey, .IdentityMap, org.eclipse.persistence.internal.security.PrivilegedAccessHelper, org.eclipse.persistence.internal.sessions.AbstractRecord, .AbstractSession, .ObjectChangeSet, org.eclipse.persistence.logging.SessionLog, org.eclipse.persistence.mappings.DatabaseMapping, org.eclipse.persistence.sessions.DatabaseSession, org.eclipse.persistence.sessions.interceptors.CacheInterceptor

Purpose: CachePolicy defines the cache configuration. EclipseLink supports an integrated shared (L2) object cache. Caching is enabled by default.
To disable caching use:
setCacheIsolation(CacheIsolationType.ISOLATED)

See Also
ClassDescriptor

Field Summary

Modifier and TypeField and Description
private Boolean
cacheable

Entity @Cacheable annotation value.

protected Map<List<DatabaseField>, CacheIndex>
protected Class<? extends CacheInterceptor>
protected String
protected CacheIsolationType
protected CacheKeyType
cacheKeyType

Allow cache key type to be configured.

protected int
cacheSynchronizationType

Configures how objects will be sent via cache synchronization, if synchronization is enabled.

protected DatabaseChangeNotificationType
databaseChangeNotificationType

Allows configuration of database change event notification.

public static final int
protected boolean
fullyMergeEntity

This flag controls how the MergeManager should merge an Entity when merging into the shared cache.

protected Class<? extends IdentityMap>
protected int
public static final int
public static final int
public static final int
public static final int
public static final int
protected boolean
prefetchCacheKeys

In certain cases and cache types it is more efficient to preFetch the cache keys from the cache when building the results of the query.

protected Class<? extends IdentityMap>
protected int
public static final int
public static final int
protected boolean
protected boolean
protected boolean
protected boolean
protected boolean
public static final int
public static final int
protected int
unitOfWorkCacheIsolationLevel

Configures how the unit of work uses the session cache.

public static final int
protected boolean

Constructor Summary

AccessConstructor and Description
public
CachePolicy()

PUBLIC: Return a new descriptor.

Method Summary

Modifier and TypeMethod and Description
public void
addCacheIndex(CacheIndex index)

PUBLIC: Add the cache index to the descriptor's cache settings.

public void
addCacheIndex(String... fields)

PUBLIC: Add the cache index to the descriptor's cache settings.

public void
addCacheIndex(DatabaseField[] fields)

PUBLIC: Add the cache index to the descriptor's cache settings.

public void
assignDefaultValues(AbstractSession session)

INTERNAL: Some attributes have default values defined in Project.

public CacheKey
checkCacheByIndex(Expression expression, AbstractRecord translationRow, ClassDescriptor descriptor, AbstractSession session)

INTERNAL: Lookup the expression in the cache if it contains any indexes.

public CachePolicy
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public void
convertClassNamesToClasses(ClassLoader classLoader)

INTERNAL: Convert all the class-name-based settings in this Descriptor to actual class-based settings.

public CacheIndex
getCacheIndex(List<DatabaseField> fields)

PUBLIC: Return the cache index for the field names.

public Map<List<DatabaseField>, CacheIndex>
public <T extends CacheInterceptor> Class<T>
getCacheInterceptorClass()

A CacheInterceptor is an adaptor that when overridden and assigned to a Descriptor all interaction between EclipseLink and the internal cache for that class will pass through the Interceptor.

public String
getCacheInterceptorClassName()

A CacheInterceptor is an adaptor that when overridden and assigned to a Descriptor all interaction between EclipseLink and the internal cache for that class will pass through the Interceptor.

public CacheIsolationType

Returns:

the isolationType
getCacheIsolation
()

PUBLIC: Controls how the Entity instances will be cached.

public CacheKeyType
getCacheKeyType()

ADVANCED: Return what cache key type to use to store the object in the cache.

public int

Returns:

int
getCacheSynchronizationType
()

PUBLIC: Get a value indicating the type of cache synchronization that will be used on objects of this type.

public DatabaseChangeNotificationType
getDatabaseChangeNotificationType()

Returns what type of database change notification an entity/descriptor should use.

public boolean

Returns:

the fullyMergeEntity
getFullyMergeEntity
()

public <T extends IdentityMap> Class<T>
getIdentityMapClass()

INTERNAL: Return the class of identity map to be used by this descriptor.

public int
getIdentityMapSize()

PUBLIC: Return the size of the identity map.

public <T extends IdentityMap> Class<T>
getRemoteIdentityMapClass()

INTERNAL: Return the class of identity map to be used by this descriptor.

public int
getRemoteIdentityMapSize()

PUBLIC: Return the size of the remote identity map.

public int
getUnitOfWorkCacheIsolationLevel()

ADVANCED: Return the unit of work cache isolation setting.

public boolean
public void
indexObjectInCache(CacheKey cacheKey, AbstractRecord databaseRow, Object domainObject, ClassDescriptor descriptor, AbstractSession session, boolean refresh)

INTERNAL: Index the object by index in the cache using its row.

public void
indexObjectInCache(CacheKey cacheKey, Object object, ClassDescriptor descriptor, AbstractSession session, boolean refresh)

INTERNAL: Index the object by index in the cache using the object.

public void
indexObjectInCache(ObjectChangeSet changeSet, Object object, ClassDescriptor descriptor, AbstractSession session)

INTERNAL: Index the object by index in the cache using its changeSet.

public void
initialize(ClassDescriptor descriptor, AbstractSession session)

INTERNAL: Allow the inheritance properties of the descriptor to be initialized.

public void
initializeFromParent(CachePolicy parentPolicy, ClassDescriptor descriptor, ClassDescriptor descriptorDescriptor, AbstractSession session)

INTERNAL: Allow the inheritance properties of the descriptor to be initialized.

public boolean
isIndexableExpression(Expression expression, ClassDescriptor descriptor, AbstractSession session)

INTERNAL: Lookup the expression in the cache if it contains any indexes.

public boolean
isIsolated()

PUBLIC: Returns true if the descriptor represents an isolated class

public boolean
isProtectedIsolation()

PUBLIC: Returns true if the descriptor represents a protected class.

public boolean
isSharedIsolation()

PUBLIC: Returns true if the descriptor represents a shared class.

public void
postInitialize(ClassDescriptor descriptor, AbstractSession session)

INTERNAL: Initialize the cache isolation setting.

public void
setCacheable(Boolean
Entity @Cacheable annotation value for current class or null if @Cacheable annotation is not set. Parent values are ignored, value shall refer to current class only.
cacheable
)

INTERNAL: Set entity @Cacheable annotation value.

public void
setCacheCoordinationType(CacheCoordinationType type)

PUBLIC: Set the type of cache coordination that will be used on objects of this type.

public void
public void
setCacheInterceptorClass(Class<? extends CacheInterceptor> cacheInterceptorClass)

PUBLIC: A CacheInterceptor is an adaptor that when overridden and assigned to a Descriptor all interaction between EclipseLink and the internal cache for that class will pass through the Interceptor.

public void
setCacheInterceptorClassName(String cacheInterceptorClassName)

PUBLIC: A CacheInterceptor is an adaptor that when overridden and assigned to a Descriptor all interaction between EclipseLink and the internal cache for that class will pass through the Interceptor.

public void
setCacheIsolation(CacheIsolationType isolationType)

PUBLIC: Controls how the Entity instances and data will be cached.

public void
setCacheKeyType(CacheKeyType cacheKeyType)

ADVANCED: Set what cache key type to use to store the object in the cache.

public void
setCacheSynchronizationType(int
int The synchronization type for this descriptor
type
)

OBSOLETE: Set the type of cache coordination that will be used on objects of this type.

public void
setDatabaseChangeNotificationType(DatabaseChangeNotificationType databaseChangeNotificationType)

Configures what type of database change notification an entity/descriptor should use.

public void
setFullyMergeEntity(boolean
the fullyMergeEntity to set
fullyMergeEntity
)

public void
setIdentityMapClass(Class<? extends IdentityMap> theIdentityMapClass)

PUBLIC: Set the class of identity map to be used by this descriptor.

public void
setIdentityMapSize(int identityMapSize)

PUBLIC: Set the size of the identity map to be used by this descriptor.

public void
setPrefetchCacheKeys(boolean prefetchCacheKeys)

public void
setRemoteIdentityMapClass(Class<? extends IdentityMap> theIdentityMapClass)

PUBLIC: Set the class of identity map to be used by this descriptor.

public void
setRemoteIdentityMapSize(int identityMapSize)

PUBLIC: Set the size of the identity map to be used by this descriptor.

public void
setShouldAlwaysRefreshCache(boolean shouldAlwaysRefreshCache)

PUBLIC: When the shouldAlwaysRefreshCache argument passed into this method is true, this method configures a ClassDescriptor to always refresh the cache if data is received from the database by any query.

public void
setShouldAlwaysRefreshCacheOnRemote(boolean shouldAlwaysRefreshCacheOnRemote)

PUBLIC: When the shouldAlwaysRefreshCacheOnRemote argument passed into this method is true, this method configures a ClassDescriptor to always remotely refresh the cache if data is received from the database by any query in a org.eclipse.persistence.sessions.remote.RemoteSession.

public void
setShouldDisableCacheHits(boolean shouldDisableCacheHits)

PUBLIC: Set if cache hits on primary key read object queries should be disabled.

public void
setShouldDisableCacheHitsOnRemote(boolean shouldDisableCacheHitsOnRemote)

PUBLIC: Set if the remote session cache hits on primary key read object queries is allowed or not.

public void
setShouldOnlyRefreshCacheIfNewerVersion(boolean shouldOnlyRefreshCacheIfNewerVersion)

PUBLIC: When the shouldOnlyRefreshCacheIfNewerVersion argument passed into this method is true, this method configures a ClassDescriptor to only refresh the cache if the data received from the database by a query is newer than the data in the cache (as determined by the optimistic locking field) and as long as one of the following is true:

public void
setUnitOfWorkCacheIsolationLevel(int unitOfWorkCacheIsolationLevel)

ADVANCED: This setting configures how the session cache will be used in a unit of work.

public boolean
shouldAlwaysRefreshCache()

PUBLIC: This method returns true if the ClassDescriptor is configured to always refresh the cache if data is received from the database by any query.

public boolean
shouldAlwaysRefreshCacheOnRemote()

PUBLIC: This method returns true if the ClassDescriptor is configured to always remotely refresh the cache if data is received from the database by any query in a org.eclipse.persistence.sessions.remote.RemoteSession.

public boolean
shouldDisableCacheHits()

PUBLIC: Return if for cache hits on primary key read object queries to be disabled.

public boolean
shouldDisableCacheHitsOnRemote()

PUBLIC: Return if the remote server session cache hits on primary key read object queries is aloowed or not.

public boolean
shouldIsolateObjectsInUnitOfWork()

INTERNAL: Return if the unit of work should by-pass the session cache.

public boolean
shouldIsolateObjectsInUnitOfWorkEarlyTransaction()

INTERNAL: Return if the unit of work should by-pass the session cache after an early transaction.

public boolean
shouldIsolateProtectedObjectsInUnitOfWork()

INTERNAL: Return if the unit of work should by-pass the IsolatedSession cache.

public boolean
shouldOnlyRefreshCacheIfNewerVersion()

PUBLIC: This method returns true if the ClassDescriptor is configured to only refresh the cache if the data received from the database by a query is newer than the data in the cache (as determined by the optimistic locking field).

public boolean
public boolean
shouldUseSessionCacheInUnitOfWorkEarlyTransaction()

INTERNAL: Return if the unit of work should use the session cache after an early transaction.

public void
useFullIdentityMap()

PUBLIC: Set the class of identity map to be the full identity map.

public void
useHardCacheWeakIdentityMap()

PUBLIC: Set the class of identity map to be the hard cache weak identity map.

public void
useNoIdentityMap()

PUBLIC: Set the class of identity map to be the no identity map.

public void
useSoftIdentityMap()

PUBLIC: Set the class of identity map to be the soft identity map.

public void
useWeakIdentityMap()

PUBLIC: Set the class of identity map to be the weak identity map.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheableback to summary
private Boolean cacheable

Entity @Cacheable annotation value. This value contains Boolean value equal to annotation value or null when no annotation was set for entity. Parent values are ignored, value refers to current class only. This value is set only when SharedCacheMode allows to override caching on entity level (DISABLE_SELECTIVE or ENABLE_SELECTIVE). Default value is null what means no annotation is present in current class.

cacheIndexesback to summary
protected Map<List<DatabaseField>, CacheIndex> cacheIndexes
cacheInterceptorClassback to summary
protected Class<? extends CacheInterceptor> cacheInterceptorClass
cacheInterceptorClassNameback to summary
protected String cacheInterceptorClassName
cacheIsolationback to summary
protected CacheIsolationType cacheIsolation
cacheKeyTypeback to summary
protected CacheKeyType cacheKeyType

Allow cache key type to be configured.

cacheSynchronizationTypeback to summary
protected int cacheSynchronizationType

Configures how objects will be sent via cache synchronization, if synchronization is enabled.

databaseChangeNotificationTypeback to summary
protected DatabaseChangeNotificationType databaseChangeNotificationType

Allows configuration of database change event notification.

DO_NOT_SEND_CHANGESback to summary
public static final int DO_NOT_SEND_CHANGES
fullyMergeEntityback to summary
protected boolean fullyMergeEntity

This flag controls how the MergeManager should merge an Entity when merging into the shared cache.

identityMapClassback to summary
protected Class<? extends IdentityMap> identityMapClass
identityMapSizeback to summary
protected int identityMapSize
INVALIDATE_CHANGED_OBJECTSback to summary
public static final int INVALIDATE_CHANGED_OBJECTS
ISOLATE_CACHE_AFTER_TRANSACTIONback to summary
public static final int ISOLATE_CACHE_AFTER_TRANSACTION
ISOLATE_CACHE_ALWAYSback to summary
public static final int ISOLATE_CACHE_ALWAYS
ISOLATE_FROM_CLIENT_SESSIONback to summary
public static final int ISOLATE_FROM_CLIENT_SESSION
ISOLATE_NEW_DATA_AFTER_TRANSACTIONback to summary
public static final int ISOLATE_NEW_DATA_AFTER_TRANSACTION
prefetchCacheKeysback to summary
protected boolean prefetchCacheKeys

In certain cases and cache types it is more efficient to preFetch the cache keys from the cache when building the results of the query. Set this flag to true to prefetch the results.

remoteIdentityMapClassback to summary
protected Class<? extends IdentityMap> remoteIdentityMapClass
remoteIdentityMapSizeback to summary
protected int remoteIdentityMapSize
SEND_NEW_OBJECTS_WITH_CHANGESback to summary
public static final int SEND_NEW_OBJECTS_WITH_CHANGES
SEND_OBJECT_CHANGESback to summary
public static final int SEND_OBJECT_CHANGES
shouldAlwaysRefreshCacheback to summary
protected boolean shouldAlwaysRefreshCache
shouldAlwaysRefreshCacheOnRemoteback to summary
protected boolean shouldAlwaysRefreshCacheOnRemote
shouldDisableCacheHitsback to summary
protected boolean shouldDisableCacheHits
shouldDisableCacheHitsOnRemoteback to summary
protected boolean shouldDisableCacheHitsOnRemote
shouldOnlyRefreshCacheIfNewerVersionback to summary
protected boolean shouldOnlyRefreshCacheIfNewerVersion
UNDEFINED_ISOLATATIONback to summary
public static final int UNDEFINED_ISOLATATION
UNDEFINED_OBJECT_CHANGE_BEHAVIORback to summary
public static final int UNDEFINED_OBJECT_CHANGE_BEHAVIOR
unitOfWorkCacheIsolationLevelback to summary
protected int unitOfWorkCacheIsolationLevel

Configures how the unit of work uses the session cache.

USE_SESSION_CACHE_AFTER_TRANSACTIONback to summary
public static final int USE_SESSION_CACHE_AFTER_TRANSACTION
wasDefaultUnitOfWorkCacheIsolationLevelback to summary
protected boolean wasDefaultUnitOfWorkCacheIsolationLevel

Constructor Detail

CachePolicyback to summary
public CachePolicy()

PUBLIC: Return a new descriptor.

Method Detail

addCacheIndexback to summary
public void addCacheIndex(CacheIndex index)

PUBLIC: Add the cache index to the descriptor's cache settings. This allows for cache hits to be obtained on non-primary key fields. The primary key is always indexed in the cache. Cache indexes are defined by their database column names.

addCacheIndexback to summary
public void addCacheIndex(String... fields)

PUBLIC: Add the cache index to the descriptor's cache settings. This allows for cache hits to be obtained on non-primary key fields. The primary key is always indexed in the cache. Cache indexes are defined by their database column names.

addCacheIndexback to summary
public void addCacheIndex(DatabaseField[] fields)

PUBLIC: Add the cache index to the descriptor's cache settings. This allows for cache hits to be obtained on non-primary key fields. The primary key is always indexed in the cache. Cache indexes are defined by their database column names.

assignDefaultValuesback to summary
public void assignDefaultValues(AbstractSession session)

INTERNAL: Some attributes have default values defined in Project. If such the value for the attribute hasn't been set then the default value is assigned.

checkCacheByIndexback to summary
public CacheKey checkCacheByIndex(Expression expression, AbstractRecord translationRow, ClassDescriptor descriptor, AbstractSession session)

INTERNAL: Lookup the expression in the cache if it contains any indexes.

cloneback to summary
public CachePolicy clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:CachePolicy

a clone of this instance.

Annotations
@Override
convertClassNamesToClassesback to summary
public void convertClassNamesToClasses(ClassLoader classLoader)

INTERNAL: Convert all the class-name-based settings in this Descriptor to actual class-based settings. This method is used when converting a project that has been built with class names to a project with classes.

getCacheIndexback to summary
public CacheIndex getCacheIndex(List<DatabaseField> fields)

PUBLIC: Return the cache index for the field names.

getCacheIndexesback to summary
public Map<List<DatabaseField>, CacheIndex> getCacheIndexes()
getCacheInterceptorClassback to summary
public <T extends CacheInterceptor> Class<T> getCacheInterceptorClass()

A CacheInterceptor is an adaptor that when overridden and assigned to a Descriptor all interaction between EclipseLink and the internal cache for that class will pass through the Interceptor. Advanced users could use this interceptor to audit, profile or log cache access. This Interceptor could also be used to redirect or augment the TopLink cache with an alternate cache mechanism. EclipseLink's configurated IdentityMaps will be passed to the Interceptor constructor. As with IdentityMaps an entire class inheritance hierarchy will share the same interceptor.

Annotations
@SuppressWarnings:unchecked
See Also
org.eclipse.persistence.sessions.interceptors.CacheInterceptor
getCacheInterceptorClassNameback to summary
public String getCacheInterceptorClassName()

A CacheInterceptor is an adaptor that when overridden and assigned to a Descriptor all interaction between EclipseLink and the internal cache for that class will pass through the Interceptor. Advanced users could use this interceptor to audit, profile or log cache access. This Interceptor could also be used to redirect or augment the TopLink cache with an alternate cache mechanism. EclipseLink's configurated IdentityMaps will be passed to the Interceptor constructor. As with IdentityMaps an entire class inheritance hierarchy will share the same interceptor.

See Also
org.eclipse.persistence.sessions.interceptors.CacheInterceptor
getCacheIsolationback to summary
public CacheIsolationType getCacheIsolation()

PUBLIC: Controls how the Entity instances will be cached. See the CacheIsolationType for details on the options.

Returns:CacheIsolationType

the isolationType

getCacheKeyTypeback to summary
public CacheKeyType getCacheKeyType()

ADVANCED: Return what cache key type to use to store the object in the cache.

getCacheSynchronizationTypeback to summary
public int getCacheSynchronizationType()

PUBLIC: Get a value indicating the type of cache synchronization that will be used on objects of this type. Possible values are: SEND_OBJECT_CHANGES INVALIDATE_CHANGED_OBJECTS SEND_NEW_OBJECTS+WITH_CHANGES DO_NOT_SEND_CHANGES

Returns:int

int

getDatabaseChangeNotificationTypeback to summary
public DatabaseChangeNotificationType getDatabaseChangeNotificationType()

Returns what type of database change notification an entity/descriptor should use. This is only relevant if the persistence unit/session has been configured with a DatabaseEventListener, such as the OracleChangeNotificationListener that receives database change events. This allows for the EclipseLink cache to be invalidated or updated from database changes.

getFullyMergeEntityback to summary
public boolean getFullyMergeEntity()
Returns:boolean

the fullyMergeEntity

getIdentityMapClassback to summary
public <T extends IdentityMap> Class<T> getIdentityMapClass()

INTERNAL: Return the class of identity map to be used by this descriptor. The default is the "SoftCacheWeakIdentityMap".

Annotations
@SuppressWarnings:unchecked
getIdentityMapSizeback to summary
public int getIdentityMapSize()

PUBLIC: Return the size of the identity map.

getRemoteIdentityMapClassback to summary
public <T extends IdentityMap> Class<T> getRemoteIdentityMapClass()

INTERNAL: Return the class of identity map to be used by this descriptor. The default is the "SoftCacheWeakIdentityMap".

Annotations
@SuppressWarnings:unchecked
getRemoteIdentityMapSizeback to summary
public int getRemoteIdentityMapSize()

PUBLIC: Return the size of the remote identity map.

getUnitOfWorkCacheIsolationLevelback to summary
public int getUnitOfWorkCacheIsolationLevel()

ADVANCED: Return the unit of work cache isolation setting. This setting configures how the session cache will be used in a unit of work.

See Also
setUnitOfWorkCacheIsolationLevel(int)
hasCacheIndexesback to summary
public boolean hasCacheIndexes()
indexObjectInCacheback to summary
public void indexObjectInCache(CacheKey cacheKey, AbstractRecord databaseRow, Object domainObject, ClassDescriptor descriptor, AbstractSession session, boolean refresh)

INTERNAL: Index the object by index in the cache using its row.

indexObjectInCacheback to summary
public void indexObjectInCache(CacheKey cacheKey, Object object, ClassDescriptor descriptor, AbstractSession session, boolean refresh)

INTERNAL: Index the object by index in the cache using the object.

indexObjectInCacheback to summary
public void indexObjectInCache(ObjectChangeSet changeSet, Object object, ClassDescriptor descriptor, AbstractSession session)

INTERNAL: Index the object by index in the cache using its changeSet.

initializeback to summary
public void initialize(ClassDescriptor descriptor, AbstractSession session) throws DescriptorException

INTERNAL: Allow the inheritance properties of the descriptor to be initialized. The descriptor's parent must first be initialized.

initializeFromParentback to summary
public void initializeFromParent(CachePolicy parentPolicy, ClassDescriptor descriptor, ClassDescriptor descriptorDescriptor, AbstractSession session) throws DescriptorException

INTERNAL: Allow the inheritance properties of the descriptor to be initialized. The descriptor's parent must first be initialized.

isIndexableExpressionback to summary
public boolean isIndexableExpression(Expression expression, ClassDescriptor descriptor, AbstractSession session)

INTERNAL: Lookup the expression in the cache if it contains any indexes.

isIsolatedback to summary
public boolean isIsolated()

PUBLIC: Returns true if the descriptor represents an isolated class

isProtectedIsolationback to summary
public boolean isProtectedIsolation()

PUBLIC: Returns true if the descriptor represents a protected class.

isSharedIsolationback to summary
public boolean isSharedIsolation()

PUBLIC: Returns true if the descriptor represents a shared class.

postInitializeback to summary
public void postInitialize(ClassDescriptor descriptor, AbstractSession session) throws DescriptorException

INTERNAL: Initialize the cache isolation setting. This may need to be called multiple times as notifyReferencingDescriptorsOfIsolation() can change the cache isolation.

setCacheableback to summary
public void setCacheable(Boolean cacheable)

INTERNAL: Set entity @Cacheable annotation value.

Parameters
cacheable:Boolean

Entity @Cacheable annotation value for current class or null if @Cacheable annotation is not set. Parent values are ignored, value shall refer to current class only.

setCacheCoordinationTypeback to summary
public void setCacheCoordinationType(CacheCoordinationType type)

PUBLIC: Set the type of cache coordination that will be used on objects of this type. Valid values defined in CacheCoordinationType.

setCacheIndexesback to summary
public void setCacheIndexes(Map<List<DatabaseField>, CacheIndex> cacheIndexes)
setCacheInterceptorClassback to summary
public void setCacheInterceptorClass(Class<? extends CacheInterceptor> cacheInterceptorClass)

PUBLIC: A CacheInterceptor is an adaptor that when overridden and assigned to a Descriptor all interaction between EclipseLink and the internal cache for that class will pass through the Interceptor. Advanced users could use this interceptor to audit, profile or log cache access. This Interceptor could also be used to redirect or augment the TopLink cache with an alternate cache mechanism. EclipseLink's configurated IdentityMaps will be passed to the Interceptor constructor. As with IdentityMaps an entire class inheritance hierarchy will share the same interceptor.

See Also
org.eclipse.persistence.sessions.interceptors.CacheInterceptor
setCacheInterceptorClassNameback to summary
public void setCacheInterceptorClassName(String cacheInterceptorClassName)

PUBLIC: A CacheInterceptor is an adaptor that when overridden and assigned to a Descriptor all interaction between EclipseLink and the internal cache for that class will pass through the Interceptor. Advanced users could use this interceptor to audit, profile or log cache access. This Interceptor could also be used to redirect or augment the TopLink cache with an alternate cache mechanism. EclipseLink's configurated IdentityMaps will be passed to the Interceptor constructor. As with IdentityMaps an entire class inheritance hierarchy will share the same interceptor.

See Also
org.eclipse.persistence.sessions.interceptors.CacheInterceptor
setCacheIsolationback to summary
public void setCacheIsolation(CacheIsolationType isolationType)

PUBLIC: Controls how the Entity instances and data will be cached. See the CacheIsolationType for details on the options. To disable all second level caching simply set CacheIsolationType.ISOLATED. Note that setting the isolation will automatically set the corresponding cacheSynchronizationType. ISOLATED = DO_NOT_SEND_CHANGES, PROTECTED and SHARED = SEND_OBJECT_CHANGES

setCacheKeyTypeback to summary
public void setCacheKeyType(CacheKeyType cacheKeyType)

ADVANCED: Set what cache key type to use to store the object in the cache.

setCacheSynchronizationTypeback to summary
public void setCacheSynchronizationType(int type)

OBSOLETE: Set the type of cache coordination that will be used on objects of this type. Possible values are:

  • SEND_OBJECT_CHANGES
  • INVALIDATE_CHANGED_OBJECTS
  • SEND_NEW_OBJECTS_WITH_CHANGES
  • DO_NOT_SEND_CHANGES
Note: Cache Synchronization type cannot be altered for descriptors that are set as isolated using the setIsIsolated method.

This has been replaced by setCacheCoordinationType().

Parameters
type:int

int The synchronization type for this descriptor

See Also
setCacheCoordinationType(CacheCoordinationType)
setDatabaseChangeNotificationTypeback to summary
public void setDatabaseChangeNotificationType(DatabaseChangeNotificationType databaseChangeNotificationType)

Configures what type of database change notification an entity/descriptor should use. This is only relevant if the persistence unit/session has been configured with a DatabaseEventListener, such as the OracleChangeNotificationListener that receives database change events. This allows for the EclipseLink cache to be invalidated or updated from database changes.

setFullyMergeEntityback to summary
public void setFullyMergeEntity(boolean fullyMergeEntity)
Parameters
fullyMergeEntity:boolean

the fullyMergeEntity to set

setIdentityMapClassback to summary
public void setIdentityMapClass(Class<? extends IdentityMap> theIdentityMapClass)

PUBLIC: Set the class of identity map to be used by this descriptor. The default is the "FullIdentityMap".

setIdentityMapSizeback to summary
public void setIdentityMapSize(int identityMapSize)

PUBLIC: Set the size of the identity map to be used by this descriptor. The default is the 100.

setPrefetchCacheKeysback to summary
public void setPrefetchCacheKeys(boolean prefetchCacheKeys)
setRemoteIdentityMapClassback to summary
public void setRemoteIdentityMapClass(Class<? extends IdentityMap> theIdentityMapClass)

PUBLIC: Set the class of identity map to be used by this descriptor. The default is the "FullIdentityMap".

setRemoteIdentityMapSizeback to summary
public void setRemoteIdentityMapSize(int identityMapSize)

PUBLIC: Set the size of the identity map to be used by this descriptor. The default is the 100.

setShouldAlwaysRefreshCacheback to summary
public void setShouldAlwaysRefreshCache(boolean shouldAlwaysRefreshCache)

PUBLIC: When the shouldAlwaysRefreshCache argument passed into this method is true, this method configures a ClassDescriptor to always refresh the cache if data is received from the database by any query.

However, if a query hits the cache, data is not refreshed regardless of how this setting is configured. For example, by default, when a query for a single object based on its primary key is executed, OracleAS TopLink will first look in the cache for the object. If the object is in the cache, the cached object is returned and data is not refreshed. To avoid cache hits, use the ClassDescriptor#disableCacheHits method.

Also note that the org.eclipse.persistence.sessions.UnitOfWork will not refresh its registered objects.

Use this property with caution because it can lead to poor performance and may refresh on queries when it is not desired. Normally, if you require fresh data, it is better to configure a query with org.eclipse.persistence.queries.ObjectLevelReadQuery#refreshIdentityMapResult. To ensure that refreshes are only done when required, use this method in conjunction with ClassDescriptor#onlyRefreshCacheIfNewerVersion.

When the shouldAlwaysRefreshCache argument passed into this method is false, this method ensures that a ClassDescriptor is not configured to always refresh the cache if data is received from the database by any query.

See Also
ClassDescriptor#alwaysRefreshCache, ClassDescriptor#dontAlwaysRefreshCache
setShouldAlwaysRefreshCacheOnRemoteback to summary
public void setShouldAlwaysRefreshCacheOnRemote(boolean shouldAlwaysRefreshCacheOnRemote)

PUBLIC: When the shouldAlwaysRefreshCacheOnRemote argument passed into this method is true, this method configures a ClassDescriptor to always remotely refresh the cache if data is received from the database by any query in a org.eclipse.persistence.sessions.remote.RemoteSession. However, if a query hits the cache, data is not refreshed regardless of how this setting is configured. For example, by default, when a query for a single object based on its primary key is executed, OracleAS TopLink will first look in the cache for the object. If the object is in the cache, the cached object is returned and data is not refreshed. To avoid cache hits, use the ClassDescriptor#disableCacheHitsOnRemote method.

Also note that the org.eclipse.persistence.sessions.UnitOfWork will not refresh its registered objects.

Use this property with caution because it can lead to poor performance and may refresh on queries when it is not desired. Normally, if you require fresh data, it is better to configure a query with org.eclipse.persistence.queries.ObjectLevelReadQuery#refreshIdentityMapResult. To ensure that refreshes are only done when required, use this method in conjunction with ClassDescriptor#onlyRefreshCacheIfNewerVersion.

When the shouldAlwaysRefreshCacheOnRemote argument passed into this method is false, this method ensures that a ClassDescriptor is not configured to always remotely refresh the cache if data is received from the database by any query in a org.eclipse.persistence.sessions.remote.RemoteSession.

See Also
ClassDescriptor#alwaysRefreshCacheOnRemote, ClassDescriptor#dontAlwaysRefreshCacheOnRemote
setShouldDisableCacheHitsback to summary
public void setShouldDisableCacheHits(boolean shouldDisableCacheHits)

PUBLIC: Set if cache hits on primary key read object queries should be disabled.

See Also
ClassDescriptor#alwaysRefreshCache()
setShouldDisableCacheHitsOnRemoteback to summary
public void setShouldDisableCacheHitsOnRemote(boolean shouldDisableCacheHitsOnRemote)

PUBLIC: Set if the remote session cache hits on primary key read object queries is allowed or not.

See Also
ClassDescriptor#disableCacheHitsOnRemote()
setShouldOnlyRefreshCacheIfNewerVersionback to summary
public void setShouldOnlyRefreshCacheIfNewerVersion(boolean shouldOnlyRefreshCacheIfNewerVersion)

PUBLIC: When the shouldOnlyRefreshCacheIfNewerVersion argument passed into this method is true, this method configures a ClassDescriptor to only refresh the cache if the data received from the database by a query is newer than the data in the cache (as determined by the optimistic locking field) and as long as one of the following is true:

However, if a query hits the cache, data is not refreshed regardless of how this setting is configured. For example, by default, when a query for a single object based on its primary key is executed, OracleAS TopLink will first look in the cache for the object. If the object is in the cache, the cached object is returned and data is not refreshed. To avoid cache hits, use the ClassDescriptor#disableCacheHits method.

Also note that the org.eclipse.persistence.sessions.UnitOfWork will not refresh its registered objects.

When the shouldOnlyRefreshCacheIfNewerVersion argument passed into this method is false, this method ensures that a ClassDescriptor is not configured to only refresh the cache if the data received from the database by a query is newer than the data in the cache (as determined by the optimistic locking field).

See Also
ClassDescriptor#onlyRefreshCacheIfNewerVersion, ClassDescriptor#dontOnlyRefreshCacheIfNewerVersion
setUnitOfWorkCacheIsolationLevelback to summary
public void setUnitOfWorkCacheIsolationLevel(int unitOfWorkCacheIsolationLevel)

ADVANCED: This setting configures how the session cache will be used in a unit of work. Most of the options only apply to a unit of work in an early transaction, such as a unit of work that was flushed (writeChanges), issued a modify query, or acquired a pessimistic lock.

USE_SESSION_CACHE_AFTER_TRANSACTION - Objects built from new data accessed after a unit of work early transaction are stored in the session cache. This options is the most efficient as it allows the cache to be used after an early transaction. This should only be used if it is known that this class is not modified in the transaction, otherwise this could cause uncommitted data to be loaded into the session cache. ISOLATE_NEW_DATA_AFTER_TRANSACTION - Default (when using caching): Objects built from new data accessed after a unit of work early transaction are only stored in the unit of work. This still allows previously cached objects to be accessed in the unit of work after an early transaction, but ensures uncommitted data will never be put in the session cache by storing any object built from new data only in the unit of work. ISOLATE_CACHE_AFTER_TRANSACTION - After a unit of work early transaction the session cache is no longer used for this class. Objects will be directly built from the database data and only stored in the unit of work, even if previously cached. Note that this may lead to poor performance as the session cache is bypassed after an early transaction. ISOLATE_CACHE_ALWAYS - Default (when using isolated cache): The session cache will never be used for this class. Objects will be directly built from the database data and only stored in the unit of work. New objects and changes will also never be merged into the session cache. Note that this may lead to poor performance as the session cache is bypassed, however if this class is isolated or pessimistic locked and always accessed in a transaction, this can avoid having to build two copies of the object.

shouldAlwaysRefreshCacheback to summary
public boolean shouldAlwaysRefreshCache()

PUBLIC: This method returns true if the ClassDescriptor is configured to always refresh the cache if data is received from the database by any query. Otherwise, it returns false.

See Also
setShouldAlwaysRefreshCache
shouldAlwaysRefreshCacheOnRemoteback to summary
public boolean shouldAlwaysRefreshCacheOnRemote()

PUBLIC: This method returns true if the ClassDescriptor is configured to always remotely refresh the cache if data is received from the database by any query in a org.eclipse.persistence.sessions.remote.RemoteSession. Otherwise, it returns false.

See Also
setShouldAlwaysRefreshCacheOnRemote
shouldDisableCacheHitsback to summary
public boolean shouldDisableCacheHits()

PUBLIC: Return if for cache hits on primary key read object queries to be disabled.

See Also
ClassDescriptor#disableCacheHits()
shouldDisableCacheHitsOnRemoteback to summary
public boolean shouldDisableCacheHitsOnRemote()

PUBLIC: Return if the remote server session cache hits on primary key read object queries is aloowed or not.

See Also
ClassDescriptor#disableCacheHitsOnRemote()
shouldIsolateObjectsInUnitOfWorkback to summary
public boolean shouldIsolateObjectsInUnitOfWork()

INTERNAL: Return if the unit of work should by-pass the session cache. Objects will be built in the unit of work, and never merged into the session cache.

shouldIsolateObjectsInUnitOfWorkEarlyTransactionback to summary
public boolean shouldIsolateObjectsInUnitOfWorkEarlyTransaction()

INTERNAL: Return if the unit of work should by-pass the session cache after an early transaction.

shouldIsolateProtectedObjectsInUnitOfWorkback to summary
public boolean shouldIsolateProtectedObjectsInUnitOfWork()

INTERNAL: Return if the unit of work should by-pass the IsolatedSession cache. Objects will be built/merged into the unit of work and into the session cache. but not built/merge into the IsolatedClientSession cache.

shouldOnlyRefreshCacheIfNewerVersionback to summary
public boolean shouldOnlyRefreshCacheIfNewerVersion()

PUBLIC: This method returns true if the ClassDescriptor is configured to only refresh the cache if the data received from the database by a query is newer than the data in the cache (as determined by the optimistic locking field). Otherwise, it returns false.

See Also
setShouldOnlyRefreshCacheIfNewerVersion
shouldPrefetchCacheKeysback to summary
public boolean shouldPrefetchCacheKeys()
shouldUseSessionCacheInUnitOfWorkEarlyTransactionback to summary
public boolean shouldUseSessionCacheInUnitOfWorkEarlyTransaction()

INTERNAL: Return if the unit of work should use the session cache after an early transaction.

useFullIdentityMapback to summary
public void useFullIdentityMap()

PUBLIC: Set the class of identity map to be the full identity map. This map caches all instances read and grows to accomodate them. The default is the "SoftCacheWeakIdentityMap".

useHardCacheWeakIdentityMapback to summary
public void useHardCacheWeakIdentityMap()

PUBLIC: Set the class of identity map to be the hard cache weak identity map. This map uses weak references to only cache object in-memory. It also includes a secondary fixed sized hard cache to improve caching performance. This is provided because some Java VM's implement soft references differently. The default is the "SoftCacheWeakIdentityMap".

useNoIdentityMapback to summary
public void useNoIdentityMap()

PUBLIC: Set the class of identity map to be the no identity map. This map does no caching.

Note

This map does not maintain object identity. In general if caching is not desired a WeakIdentityMap should be used with an isolated descriptor. The default is the "SoftCacheWeakIdentityMap".

See Also
ClassDescriptor#setCacheIsolation(CacheIsolationType)
useSoftIdentityMapback to summary
public void useSoftIdentityMap()

PUBLIC: Set the class of identity map to be the soft identity map. This map uses soft references to only cache all object in-memory, until memory is low. Note that "low" is interpreted differently by different JVM's. The default is the "SoftCacheWeakIdentityMap".

useWeakIdentityMapback to summary
public void useWeakIdentityMap()

PUBLIC: Set the class of identity map to be the weak identity map. The default is the "SoftCacheWeakIdentityMap".