Class CachePolicy
- java.lang.Object
-
- org.eclipse.persistence.descriptors.CachePolicy
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
public class CachePolicy extends java.lang.Object implements java.lang.Cloneable, java.io.SerializablePurpose: 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, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.util.List<org.eclipse.persistence.internal.helper.DatabaseField>,CacheIndex>cacheIndexesprotected java.lang.ClasscacheInterceptorClassprotected java.lang.StringcacheInterceptorClassNameprotected CacheIsolationTypecacheIsolationprotected CacheKeyTypecacheKeyTypeAllow cache key type to be configured.protected intcacheSynchronizationTypeConfigures how objects will be sent via cache synchronization, if synchronization is enabled.protected DatabaseChangeNotificationTypedatabaseChangeNotificationTypeAllows configuration of database change event notification.static intDO_NOT_SEND_CHANGESprotected booleanfullyMergeEntityThis flag controls how the MergeManager should merge an Entity when merging into the shared cache.protected java.lang.ClassidentityMapClassprotected intidentityMapSizestatic intINVALIDATE_CHANGED_OBJECTSstatic intISOLATE_CACHE_AFTER_TRANSACTIONstatic intISOLATE_CACHE_ALWAYSstatic intISOLATE_FROM_CLIENT_SESSIONstatic intISOLATE_NEW_DATA_AFTER_TRANSACTIONprotected booleanprefetchCacheKeysIn 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 java.lang.ClassremoteIdentityMapClassprotected intremoteIdentityMapSizestatic intSEND_NEW_OBJECTS_WITH_CHANGESstatic intSEND_OBJECT_CHANGESprotected booleanshouldAlwaysRefreshCacheprotected booleanshouldAlwaysRefreshCacheOnRemoteprotected booleanshouldDisableCacheHitsprotected booleanshouldDisableCacheHitsOnRemoteprotected booleanshouldOnlyRefreshCacheIfNewerVersionstatic intUNDEFINED_ISOLATATIONstatic intUNDEFINED_OBJECT_CHANGE_BEHAVIORprotected intunitOfWorkCacheIsolationLevelConfigures how the unit of work uses the session cache.static intUSE_SESSION_CACHE_AFTER_TRANSACTIONprotected booleanwasDefaultUnitOfWorkCacheIsolationLevel
-
Constructor Summary
Constructors Constructor Description CachePolicy()PUBLIC: Return a new descriptor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCacheIndex(java.lang.String... fields)PUBLIC: Add the cache index to the descriptor's cache settings.voidaddCacheIndex(CacheIndex index)PUBLIC: Add the cache index to the descriptor's cache settings.voidaddCacheIndex(org.eclipse.persistence.internal.helper.DatabaseField[] fields)PUBLIC: Add the cache index to the descriptor's cache settings.voidassignDefaultValues(org.eclipse.persistence.internal.sessions.AbstractSession session)INTERNAL: Some attributes have default values defined in Project.org.eclipse.persistence.internal.identitymaps.CacheKeycheckCacheByIndex(Expression expression, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow, ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session)INTERNAL: Lookup the expression in the cache if it contains any indexes.CachePolicyclone()voidconvertClassNamesToClasses(java.lang.ClassLoader classLoader)INTERNAL: Convert all the class-name-based settings in this Descriptor to actual class-based settings.CacheIndexgetCacheIndex(java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> fields)PUBLIC: Return the cache index for the field names.java.util.Map<java.util.List<org.eclipse.persistence.internal.helper.DatabaseField>,CacheIndex>getCacheIndexes()java.lang.ClassgetCacheInterceptorClass()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.java.lang.StringgetCacheInterceptorClassName()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.CacheIsolationTypegetCacheIsolation()PUBLIC: Controls how the Entity instances will be cached.CacheKeyTypegetCacheKeyType()ADVANCED: Return what cache key type to use to store the object in the cache.intgetCacheSynchronizationType()PUBLIC: Get a value indicating the type of cache synchronization that will be used on objects of this type.DatabaseChangeNotificationTypegetDatabaseChangeNotificationType()Returns what type of database change notification an entity/descriptor should use.booleangetFullyMergeEntity()java.lang.ClassgetIdentityMapClass()INTERNAL: Return the class of identity map to be used by this descriptor.intgetIdentityMapSize()PUBLIC: Return the size of the identity map.java.lang.ClassgetRemoteIdentityMapClass()INTERNAL: Return the class of identity map to be used by this descriptor.intgetRemoteIdentityMapSize()PUBLIC: Return the size of the remote identity map.intgetUnitOfWorkCacheIsolationLevel()ADVANCED: Return the unit of work cache isolation setting.booleanhasCacheIndexes()voidindexObjectInCache(org.eclipse.persistence.internal.identitymaps.CacheKey cacheKey, java.lang.Object object, ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session, boolean refresh)INTERNAL: Index the object by index in the cache using the object.voidindexObjectInCache(org.eclipse.persistence.internal.identitymaps.CacheKey cacheKey, org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow, java.lang.Object domainObject, ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session, boolean refresh)INTERNAL: Index the object by index in the cache using its row.voidindexObjectInCache(org.eclipse.persistence.internal.sessions.ObjectChangeSet changeSet, java.lang.Object object, ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session)INTERNAL: Index the object by index in the cache using its changeSet.voidinitialize(ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session)INTERNAL: Allow the inheritance properties of the descriptor to be initialized.voidinitializeFromParent(CachePolicy parentPolicy, ClassDescriptor descriptor, ClassDescriptor descriptorDescriptor, org.eclipse.persistence.internal.sessions.AbstractSession session)INTERNAL: Allow the inheritance properties of the descriptor to be initialized.booleanisIndexableExpression(Expression expression, ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session)INTERNAL: Lookup the expression in the cache if it contains any indexes.booleanisIsolated()PUBLIC: Returns true if the descriptor represents an isolated classbooleanisProtectedIsolation()PUBLIC: Returns true if the descriptor represents a protected class.booleanisSharedIsolation()PUBLIC: Returns true if the descriptor represents a shared class.voidpostInitialize(ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session)INTERNAL: Initialize the cache isolation setting.voidsetCacheable(java.lang.Boolean cacheable)INTERNAL: Set entity @Cacheable annotation value.voidsetCacheCoordinationType(CacheCoordinationType type)PUBLIC: Set the type of cache coordination that will be used on objects of this type.voidsetCacheIndexes(java.util.Map<java.util.List<org.eclipse.persistence.internal.helper.DatabaseField>,CacheIndex> cacheIndexes)voidsetCacheInterceptorClass(java.lang.Class 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.voidsetCacheInterceptorClassName(java.lang.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.voidsetCacheIsolation(CacheIsolationType isolationType)PUBLIC: Controls how the Entity instances and data will be cached.voidsetCacheKeyType(CacheKeyType cacheKeyType)ADVANCED: Set what cache key type to use to store the object in the cache.voidsetCacheSynchronizationType(int type)OBSOLETE: Set the type of cache coordination that will be used on objects of this type.voidsetDatabaseChangeNotificationType(DatabaseChangeNotificationType databaseChangeNotificationType)Configures what type of database change notification an entity/descriptor should use.voidsetFullyMergeEntity(boolean fullyMergeEntity)voidsetIdentityMapClass(java.lang.Class theIdentityMapClass)PUBLIC: Set the class of identity map to be used by this descriptor.voidsetIdentityMapSize(int identityMapSize)PUBLIC: Set the size of the identity map to be used by this descriptor.voidsetPrefetchCacheKeys(boolean prefetchCacheKeys)voidsetRemoteIdentityMapClass(java.lang.Class theIdentityMapClass)PUBLIC: Set the class of identity map to be used by this descriptor.voidsetRemoteIdentityMapSize(int identityMapSize)PUBLIC: Set the size of the identity map to be used by this descriptor.voidsetShouldAlwaysRefreshCache(boolean shouldAlwaysRefreshCache)PUBLIC: When theshouldAlwaysRefreshCacheargument passed into this method istrue, this method configures aClassDescriptorto always refresh the cache if data is received from the database by any query.voidsetShouldAlwaysRefreshCacheOnRemote(boolean shouldAlwaysRefreshCacheOnRemote)PUBLIC: When theshouldAlwaysRefreshCacheOnRemoteargument passed into this method istrue, this method configures aClassDescriptorto always remotely refresh the cache if data is received from the database by any query in aRemoteSession.voidsetShouldDisableCacheHits(boolean shouldDisableCacheHits)PUBLIC: Set if cache hits on primary key read object queries should be disabled.voidsetShouldDisableCacheHitsOnRemote(boolean shouldDisableCacheHitsOnRemote)PUBLIC: Set if the remote session cache hits on primary key read object queries is allowed or not.voidsetShouldOnlyRefreshCacheIfNewerVersion(boolean shouldOnlyRefreshCacheIfNewerVersion)PUBLIC: When theshouldOnlyRefreshCacheIfNewerVersionargument passed into this method istrue, this method configures aClassDescriptorto 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: theClassDescriptorwas configured by callingClassDescriptor.alwaysRefreshCache()orClassDescriptor.alwaysRefreshCacheOnRemote(), the query was configured by callingObjectLevelReadQuery.refreshIdentityMapResult(), or the query was a call toSession.refreshObject(java.lang.Object)voidsetUnitOfWorkCacheIsolationLevel(int unitOfWorkCacheIsolationLevel)ADVANCED: This setting configures how the session cache will be used in a unit of work.booleanshouldAlwaysRefreshCache()PUBLIC: This method returnstrueif theClassDescriptoris configured to always refresh the cache if data is received from the database by any query.booleanshouldAlwaysRefreshCacheOnRemote()PUBLIC: This method returnstrueif theClassDescriptoris configured to always remotely refresh the cache if data is received from the database by any query in aRemoteSession.booleanshouldDisableCacheHits()PUBLIC: Return if for cache hits on primary key read object queries to be disabled.booleanshouldDisableCacheHitsOnRemote()PUBLIC: Return if the remote server session cache hits on primary key read object queries is aloowed or not.booleanshouldIsolateObjectsInUnitOfWork()INTERNAL: Return if the unit of work should by-pass the session cache.booleanshouldIsolateObjectsInUnitOfWorkEarlyTransaction()INTERNAL: Return if the unit of work should by-pass the session cache after an early transaction.booleanshouldIsolateProtectedObjectsInUnitOfWork()INTERNAL: Return if the unit of work should by-pass the IsolatedSession cache.booleanshouldOnlyRefreshCacheIfNewerVersion()PUBLIC: This method returnstrueif theClassDescriptoris 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).booleanshouldPrefetchCacheKeys()booleanshouldUseSessionCacheInUnitOfWorkEarlyTransaction()INTERNAL: Return if the unit of work should use the session cache after an early transaction.voiduseFullIdentityMap()PUBLIC: Set the class of identity map to be the full identity map.voiduseHardCacheWeakIdentityMap()PUBLIC: Set the class of identity map to be the hard cache weak identity map.voiduseNoIdentityMap()PUBLIC: Set the class of identity map to be the no identity map.voiduseSoftIdentityMap()PUBLIC: Set the class of identity map to be the soft identity map.voiduseWeakIdentityMap()PUBLIC: Set the class of identity map to be the weak identity map.
-
-
-
Field Detail
-
identityMapClass
protected java.lang.Class identityMapClass
-
identityMapSize
protected int identityMapSize
-
shouldAlwaysRefreshCache
protected boolean shouldAlwaysRefreshCache
-
shouldOnlyRefreshCacheIfNewerVersion
protected boolean shouldOnlyRefreshCacheIfNewerVersion
-
shouldDisableCacheHits
protected boolean shouldDisableCacheHits
-
remoteIdentityMapClass
protected java.lang.Class remoteIdentityMapClass
-
remoteIdentityMapSize
protected int remoteIdentityMapSize
-
shouldAlwaysRefreshCacheOnRemote
protected boolean shouldAlwaysRefreshCacheOnRemote
-
shouldDisableCacheHitsOnRemote
protected boolean shouldDisableCacheHitsOnRemote
-
cacheIsolation
protected CacheIsolationType cacheIsolation
-
cacheSynchronizationType
protected int cacheSynchronizationType
Configures how objects will be sent via cache synchronization, if synchronization is enabled.
-
UNDEFINED_OBJECT_CHANGE_BEHAVIOR
public static final int UNDEFINED_OBJECT_CHANGE_BEHAVIOR
- See Also:
- Constant Field Values
-
SEND_OBJECT_CHANGES
public static final int SEND_OBJECT_CHANGES
- See Also:
- Constant Field Values
-
INVALIDATE_CHANGED_OBJECTS
public static final int INVALIDATE_CHANGED_OBJECTS
- See Also:
- Constant Field Values
-
SEND_NEW_OBJECTS_WITH_CHANGES
public static final int SEND_NEW_OBJECTS_WITH_CHANGES
- See Also:
- Constant Field Values
-
DO_NOT_SEND_CHANGES
public static final int DO_NOT_SEND_CHANGES
- See Also:
- Constant Field Values
-
unitOfWorkCacheIsolationLevel
protected int unitOfWorkCacheIsolationLevel
Configures how the unit of work uses the session cache.
-
wasDefaultUnitOfWorkCacheIsolationLevel
protected boolean wasDefaultUnitOfWorkCacheIsolationLevel
-
UNDEFINED_ISOLATATION
public static final int UNDEFINED_ISOLATATION
- See Also:
- Constant Field Values
-
USE_SESSION_CACHE_AFTER_TRANSACTION
public static final int USE_SESSION_CACHE_AFTER_TRANSACTION
- See Also:
- Constant Field Values
-
ISOLATE_NEW_DATA_AFTER_TRANSACTION
public static final int ISOLATE_NEW_DATA_AFTER_TRANSACTION
- See Also:
- Constant Field Values
-
ISOLATE_CACHE_AFTER_TRANSACTION
public static final int ISOLATE_CACHE_AFTER_TRANSACTION
- See Also:
- Constant Field Values
-
ISOLATE_FROM_CLIENT_SESSION
public static final int ISOLATE_FROM_CLIENT_SESSION
- See Also:
- Constant Field Values
-
ISOLATE_CACHE_ALWAYS
public static final int ISOLATE_CACHE_ALWAYS
- See Also:
- Constant Field Values
-
cacheKeyType
protected CacheKeyType cacheKeyType
Allow cache key type to be configured.
-
cacheInterceptorClass
protected java.lang.Class cacheInterceptorClass
-
cacheInterceptorClassName
protected java.lang.String cacheInterceptorClassName
-
fullyMergeEntity
protected boolean fullyMergeEntity
This flag controls how the MergeManager should merge an Entity when merging into the shared cache.
-
prefetchCacheKeys
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.
-
cacheIndexes
protected java.util.Map<java.util.List<org.eclipse.persistence.internal.helper.DatabaseField>,CacheIndex> cacheIndexes
-
databaseChangeNotificationType
protected DatabaseChangeNotificationType databaseChangeNotificationType
Allows configuration of database change event notification.
-
-
Method Detail
-
getDatabaseChangeNotificationType
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.
-
setDatabaseChangeNotificationType
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.
-
initializeFromParent
public void initializeFromParent(CachePolicy parentPolicy, ClassDescriptor descriptor, ClassDescriptor descriptorDescriptor, org.eclipse.persistence.internal.sessions.AbstractSession session) throws DescriptorException
INTERNAL: Allow the inheritance properties of the descriptor to be initialized. The descriptor's parent must first be initialized.- Throws:
DescriptorException
-
postInitialize
public void postInitialize(ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.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.- Throws:
DescriptorException
-
initialize
public void initialize(ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session) throws DescriptorException
INTERNAL: Allow the inheritance properties of the descriptor to be initialized. The descriptor's parent must first be initialized.- Throws:
DescriptorException
-
getCacheIndex
public CacheIndex getCacheIndex(java.util.List<org.eclipse.persistence.internal.helper.DatabaseField> fields)
PUBLIC: Return the cache index for the field names.
-
addCacheIndex
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.
-
addCacheIndex
public void addCacheIndex(java.lang.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.
-
addCacheIndex
public void addCacheIndex(org.eclipse.persistence.internal.helper.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.
-
hasCacheIndexes
public boolean hasCacheIndexes()
-
getCacheIndexes
public java.util.Map<java.util.List<org.eclipse.persistence.internal.helper.DatabaseField>,CacheIndex> getCacheIndexes()
-
setCacheIndexes
public void setCacheIndexes(java.util.Map<java.util.List<org.eclipse.persistence.internal.helper.DatabaseField>,CacheIndex> cacheIndexes)
-
clone
public CachePolicy clone()
- Overrides:
clonein classjava.lang.Object
-
assignDefaultValues
public void assignDefaultValues(org.eclipse.persistence.internal.sessions.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.
-
convertClassNamesToClasses
public void convertClassNamesToClasses(java.lang.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.- Parameters:
classLoader-
-
getFullyMergeEntity
public boolean getFullyMergeEntity()
- Returns:
- the fullyMergeEntity
-
setCacheKeyType
public void setCacheKeyType(CacheKeyType cacheKeyType)
ADVANCED: Set what cache key type to use to store the object in the cache.
-
getCacheKeyType
public CacheKeyType getCacheKeyType()
ADVANCED: Return what cache key type to use to store the object in the cache.
-
getCacheInterceptorClass
public java.lang.Class 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.- See Also:
CacheInterceptor
-
getCacheInterceptorClassName
public java.lang.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:
CacheInterceptor
-
getCacheSynchronizationType
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
-
getIdentityMapClass
public java.lang.Class getIdentityMapClass()
INTERNAL: Return the class of identity map to be used by this descriptor. The default is the "SoftCacheWeakIdentityMap".
-
getIdentityMapSize
public int getIdentityMapSize()
PUBLIC: Return the size of the identity map.
-
getRemoteIdentityMapClass
public java.lang.Class getRemoteIdentityMapClass()
INTERNAL: Return the class of identity map to be used by this descriptor. The default is the "SoftCacheWeakIdentityMap".
-
getRemoteIdentityMapSize
public int getRemoteIdentityMapSize()
PUBLIC: Return the size of the remote identity map.
-
shouldDisableCacheHits
public boolean shouldDisableCacheHits()
PUBLIC: Return if for cache hits on primary key read object queries to be disabled.- See Also:
ClassDescriptor.disableCacheHits()
-
shouldDisableCacheHitsOnRemote
public boolean shouldDisableCacheHitsOnRemote()
PUBLIC: Return if the remote server session cache hits on primary key read object queries is aloowed or not.
-
shouldOnlyRefreshCacheIfNewerVersion
public boolean shouldOnlyRefreshCacheIfNewerVersion()
PUBLIC: This method returnstrueif theClassDescriptoris 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 returnsfalse.
-
shouldAlwaysRefreshCache
public boolean shouldAlwaysRefreshCache()
PUBLIC: This method returnstrueif theClassDescriptoris configured to always refresh the cache if data is received from the database by any query. Otherwise, it returnsfalse.- See Also:
setShouldAlwaysRefreshCache(boolean)
-
shouldAlwaysRefreshCacheOnRemote
public boolean shouldAlwaysRefreshCacheOnRemote()
PUBLIC: This method returnstrueif theClassDescriptoris configured to always remotely refresh the cache if data is received from the database by any query in aRemoteSession. Otherwise, it returnsfalse.
-
setShouldDisableCacheHits
public void setShouldDisableCacheHits(boolean shouldDisableCacheHits)
PUBLIC: Set if cache hits on primary key read object queries should be disabled.- See Also:
ClassDescriptor.alwaysRefreshCache()
-
setShouldDisableCacheHitsOnRemote
public void setShouldDisableCacheHitsOnRemote(boolean shouldDisableCacheHitsOnRemote)
PUBLIC: Set if the remote session cache hits on primary key read object queries is allowed or not.
-
setShouldOnlyRefreshCacheIfNewerVersion
public void setShouldOnlyRefreshCacheIfNewerVersion(boolean shouldOnlyRefreshCacheIfNewerVersion)
PUBLIC: When theshouldOnlyRefreshCacheIfNewerVersionargument passed into this method istrue, this method configures aClassDescriptorto 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:- the
ClassDescriptorwas configured by callingClassDescriptor.alwaysRefreshCache()orClassDescriptor.alwaysRefreshCacheOnRemote(), - the query was configured by calling
ObjectLevelReadQuery.refreshIdentityMapResult(), or - the query was a call to
Session.refreshObject(java.lang.Object)
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
UnitOfWorkwill not refresh its registered objects.When the
shouldOnlyRefreshCacheIfNewerVersionargument passed into this method isfalse, this method ensures that aClassDescriptoris 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). - the
-
setShouldAlwaysRefreshCache
public void setShouldAlwaysRefreshCache(boolean shouldAlwaysRefreshCache)
PUBLIC: When theshouldAlwaysRefreshCacheargument passed into this method istrue, this method configures aClassDescriptorto 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
UnitOfWorkwill 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
ObjectLevelReadQuery.refreshIdentityMapResult(). To ensure that refreshes are only done when required, use this method in conjunction withClassDescriptor.onlyRefreshCacheIfNewerVersion().When the
shouldAlwaysRefreshCacheargument passed into this method isfalse, this method ensures that aClassDescriptoris not configured to always refresh the cache if data is received from the database by any query.
-
setShouldAlwaysRefreshCacheOnRemote
public void setShouldAlwaysRefreshCacheOnRemote(boolean shouldAlwaysRefreshCacheOnRemote)
PUBLIC: When theshouldAlwaysRefreshCacheOnRemoteargument passed into this method istrue, this method configures aClassDescriptorto always remotely refresh the cache if data is received from the database by any query in aRemoteSession. 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 theClassDescriptor.disableCacheHitsOnRemote()method.Also note that the
UnitOfWorkwill 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
ObjectLevelReadQuery.refreshIdentityMapResult(). To ensure that refreshes are only done when required, use this method in conjunction withClassDescriptor.onlyRefreshCacheIfNewerVersion().When the
shouldAlwaysRefreshCacheOnRemoteargument passed into this method isfalse, this method ensures that aClassDescriptoris not configured to always remotely refresh the cache if data is received from the database by any query in aRemoteSession.
-
setRemoteIdentityMapClass
public void setRemoteIdentityMapClass(java.lang.Class theIdentityMapClass)
PUBLIC: Set the class of identity map to be used by this descriptor. The default is the "FullIdentityMap".
-
setRemoteIdentityMapSize
public void setRemoteIdentityMapSize(int identityMapSize)
PUBLIC: Set the size of the identity map to be used by this descriptor. The default is the 100.
-
setCacheable
public void setCacheable(java.lang.Boolean cacheable)
INTERNAL: Set entity @Cacheable annotation value.- Parameters:
cacheable- Entity @Cacheable annotation value for current class ornullif @Cacheable annotation is not set. Parent values are ignored, value shall refer to current class only.
-
getCacheIsolation
public CacheIsolationType getCacheIsolation()
PUBLIC: Controls how the Entity instances will be cached. See the CacheIsolationType for details on the options.- Returns:
- the isolationType
-
setCacheIsolation
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
-
shouldIsolateObjectsInUnitOfWork
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.
-
shouldIsolateProtectedObjectsInUnitOfWork
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.
-
shouldIsolateObjectsInUnitOfWorkEarlyTransaction
public boolean shouldIsolateObjectsInUnitOfWorkEarlyTransaction()
INTERNAL: Return if the unit of work should by-pass the session cache after an early transaction.
-
shouldUseSessionCacheInUnitOfWorkEarlyTransaction
public boolean shouldUseSessionCacheInUnitOfWorkEarlyTransaction()
INTERNAL: Return if the unit of work should use the session cache after an early transaction.
-
getUnitOfWorkCacheIsolationLevel
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)
-
setUnitOfWorkCacheIsolationLevel
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.
-
setFullyMergeEntity
public void setFullyMergeEntity(boolean fullyMergeEntity)
- Parameters:
fullyMergeEntity- the fullyMergeEntity to set
-
setIdentityMapClass
public void setIdentityMapClass(java.lang.Class theIdentityMapClass)
PUBLIC: Set the class of identity map to be used by this descriptor. The default is the "FullIdentityMap".
-
setIdentityMapSize
public void setIdentityMapSize(int identityMapSize)
PUBLIC: Set the size of the identity map to be used by this descriptor. The default is the 100.
-
setCacheSynchronizationType
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
This has been replaced by setCacheCoordinationType().
- Parameters:
type- int The synchronization type for this descriptor- See Also:
setCacheCoordinationType(CacheCoordinationType)
-
setCacheCoordinationType
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.
-
setCacheInterceptorClass
public void setCacheInterceptorClass(java.lang.Class 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:
CacheInterceptor
-
setCacheInterceptorClassName
public void setCacheInterceptorClassName(java.lang.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:
CacheInterceptor
-
isIsolated
public boolean isIsolated()
PUBLIC: Returns true if the descriptor represents an isolated class
-
isProtectedIsolation
public boolean isProtectedIsolation()
PUBLIC: Returns true if the descriptor represents a protected class.
-
isSharedIsolation
public boolean isSharedIsolation()
PUBLIC: Returns true if the descriptor represents a shared class.
-
indexObjectInCache
public void indexObjectInCache(org.eclipse.persistence.internal.identitymaps.CacheKey cacheKey, org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow, java.lang.Object domainObject, ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session, boolean refresh)INTERNAL: Index the object by index in the cache using its row.
-
indexObjectInCache
public void indexObjectInCache(org.eclipse.persistence.internal.identitymaps.CacheKey cacheKey, java.lang.Object object, ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session, boolean refresh)INTERNAL: Index the object by index in the cache using the object.
-
indexObjectInCache
public void indexObjectInCache(org.eclipse.persistence.internal.sessions.ObjectChangeSet changeSet, java.lang.Object object, ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session)INTERNAL: Index the object by index in the cache using its changeSet.
-
checkCacheByIndex
public org.eclipse.persistence.internal.identitymaps.CacheKey checkCacheByIndex(Expression expression, org.eclipse.persistence.internal.sessions.AbstractRecord translationRow, ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Lookup the expression in the cache if it contains any indexes.
-
isIndexableExpression
public boolean isIndexableExpression(Expression expression, ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Lookup the expression in the cache if it contains any indexes.
-
useFullIdentityMap
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".
-
useHardCacheWeakIdentityMap
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".
-
useSoftIdentityMap
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".
-
useNoIdentityMap
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.setIsIsolated(boolean)
-
useWeakIdentityMap
public void useWeakIdentityMap()
PUBLIC: Set the class of identity map to be the weak identity map. The default is the "SoftCacheWeakIdentityMap".
-
setPrefetchCacheKeys
public void setPrefetchCacheKeys(boolean prefetchCacheKeys)
-
shouldPrefetchCacheKeys
public boolean shouldPrefetchCacheKeys()
-
-