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

public Class QueryResultsCachePolicy

extends Object
implements Serializable, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, java.io.Serializable
Imports
java.io.Serializable, java.util.HashSet, .Set, org.eclipse.persistence.descriptors.invalidation.*, org.eclipse.persistence.internal.helper.ClassConstants, org.eclipse.persistence.internal.identitymaps.IdentityMap

PUBLIC: A QueryResultsCache policy dictates how a query's results will be cached. It allows an invalidation policy and a maximum number of results to be set. Query results are cached based on the parameter values of a query, and the maximum number of results refers to the maximum number of parameter sets results will be cached for.\ By default query result caching is not used.
See Also
org.eclipse.persistence.queries.ReadQuery#setQueryResultsCachePolicy(QueryResultsCachePolicy)

Field Summary

Modifier and TypeField and Description
protected Class<? extends IdentityMap>
cacheType

Allows the identity map class type to be set.

protected boolean
invalidateOnChange

Allows the query cache to be invalidated when any object of any of the query classes is modified.

protected Set<Class<?>>
invalidationClasses

Stores the set of classes that should trigger the query cached results to be invalidated.

protected CacheInvalidationPolicy
invalidationPolicy

Allows invalidation to be specified.

protected boolean
isNullIgnored

Allows the caching of null to be configured.

protected int
maximumResultSets

Specifies the cache size.

Constructor Summary

AccessConstructor and Description
public
QueryResultsCachePolicy()

PUBLIC: Build a QueryResultsCachePolicy with the default settings By default there is no invalidation of query results and the maximum number of results sets is 100.

public
QueryResultsCachePolicy(CacheInvalidationPolicy policy, int maximumResultSets)

PUBLIC: Build a QueryResultsCachePolicy and supply a CacheInvalidationPolicy and a maximum number of results sets.

public
QueryResultsCachePolicy(CacheInvalidationPolicy policy)

PUBLIC: Build a QueryResultsCachePolicy and supply a CacheInvalidationPolicy.

public
QueryResultsCachePolicy(int maximumResultSets)

PUBLIC: Build a QueryResultsCachePolicy and supply a maximum for the number of results sets.

Method Summary

Modifier and TypeMethod and Description
public QueryResultsCachePolicy
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public CacheInvalidationPolicy
getCacheInvalidationPolicy()

PUBLIC: Return the query cache invalidation policy.

public Class<? extends IdentityMap>
getCacheType()

PUBLIC: Return the type of the cache used for the query results.

public boolean
getInvalidateOnChange()

PUBLIC: Return if any change to any object of the query class should cause the query results to be invalidated.

public Set<Class<?>>
getInvalidationClasses()

ADVANCED: Return the set of classes that should trigger the query cached results to be invalidated.

public int
getMaximumCachedResults()

PUBLIC: Return the maximum cached results.

public boolean
isNullIgnored()

PUBLIC: Return if null results should be cached or ignored.

public void
setCacheInvalidationPolicy(CacheInvalidationPolicy invalidationPolicy)

PUBLIC: Set the query cache invalidation policy.

public void
setCacheType(Class<? extends IdentityMap> cacheType)

PUBLIC: Set the type of the cache used for the query results.

public void
setInvalidateOnChange(boolean invalidateOnChange)

PUBLIC: Configure if any change to any object of the query class should cause the query results to be invalidated.

public void
setInvalidationClasses(Set<Class<?>> invalidationClasses)

ADVANCED: Set the set of classes that should trigger the query cached results to be invalidated.

public void
setIsNullIgnored(boolean isNullIgnored)

PUBLIC: Set if null results should be cached or ignored.

public void
setMaximumCachedResults(int maximumResultSets)

PUBLIC: Set the maximum cached results.

public void
useFullCache()

PUBLIC: Set the type of the cache used for the query results to a FullIdentityMap.

public void
useLRUCache()

PUBLIC: Set the type of the cache used for the query results to a CacheIdentityMap.

public void
useSoftCache()

PUBLIC: Set the type of the cache used for the query results to a SoftIdentityMap.

public void
useSoftLRUCache()

PUBLIC: Set the type of the cache used for the query results to a SoftCacheWeakIdentityMap.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheTypeback to summary
protected Class<? extends IdentityMap> cacheType

Allows the identity map class type to be set.

invalidateOnChangeback to summary
protected boolean invalidateOnChange

Allows the query cache to be invalidated when any object of any of the query classes is modified.

invalidationClassesback to summary
protected Set<Class<?>> invalidationClasses

Stores the set of classes that should trigger the query cached results to be invalidated.

invalidationPolicyback to summary
protected CacheInvalidationPolicy invalidationPolicy

Allows invalidation to be specified.

isNullIgnoredback to summary
protected boolean isNullIgnored

Allows the caching of null to be configured.

maximumResultSetsback to summary
protected int maximumResultSets

Specifies the cache size.

Constructor Detail

QueryResultsCachePolicyback to summary
public QueryResultsCachePolicy()

PUBLIC: Build a QueryResultsCachePolicy with the default settings By default there is no invalidation of query results and the maximum number of results sets is 100.

QueryResultsCachePolicyback to summary
public QueryResultsCachePolicy(CacheInvalidationPolicy policy, int maximumResultSets)

PUBLIC: Build a QueryResultsCachePolicy and supply a CacheInvalidationPolicy and a maximum number of results sets.

See Also
org.eclipse.persistence.descriptors.invalidation.CacheInvalidationPolicy
QueryResultsCachePolicyback to summary
public QueryResultsCachePolicy(CacheInvalidationPolicy policy)

PUBLIC: Build a QueryResultsCachePolicy and supply a CacheInvalidationPolicy. The default value of 100 will be used for the maximum number of result sets

See Also
org.eclipse.persistence.descriptors.invalidation.CacheInvalidationPolicy
QueryResultsCachePolicyback to summary
public QueryResultsCachePolicy(int maximumResultSets)

PUBLIC: Build a QueryResultsCachePolicy and supply a maximum for the number of results sets. Results will be set not to expire in the cache.

Method Detail

cloneback to summary
public QueryResultsCachePolicy 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:QueryResultsCachePolicy

a clone of this instance.

Annotations
@Override
getCacheInvalidationPolicyback to summary
public CacheInvalidationPolicy getCacheInvalidationPolicy()

PUBLIC: Return the query cache invalidation policy. The cache invalidation policy defines how the query results are invalidated.

getCacheTypeback to summary
public Class<? extends IdentityMap> getCacheType()

PUBLIC: Return the type of the cache used for the query results. This defaults to a LRU cache (CacheIdentityMap), but can be set to any IdentityMap class, such as Full or Soft.

getInvalidateOnChangeback to summary
public boolean getInvalidateOnChange()

PUBLIC: Return if any change to any object of the query class should cause the query results to be invalidated.

getInvalidationClassesback to summary
public Set<Class<?>> getInvalidationClasses()

ADVANCED: Return the set of classes that should trigger the query cached results to be invalidated.

getMaximumCachedResultsback to summary
public int getMaximumCachedResults()

PUBLIC: Return the maximum cached results. This defines the number of query result sets that will be cached. The LRU query results will be discarded when the max size is reached.

isNullIgnoredback to summary
public boolean isNullIgnored()

PUBLIC: Return if null results should be cached or ignored. By default they are cached. They can be ignored to allow a query cache to be used as a secondary cache index, and allow new objects to be insert, and still found.

setCacheInvalidationPolicyback to summary
public void setCacheInvalidationPolicy(CacheInvalidationPolicy invalidationPolicy)

PUBLIC: Set the query cache invalidation policy. The cache invalidation policy defines how the query results are invalidated.

setCacheTypeback to summary
public void setCacheType(Class<? extends IdentityMap> cacheType)

PUBLIC: Set the type of the cache used for the query results. This defaults to a LRU cache (CacheIdentityMap), but can be set to any IdentityMap class, such as Full or Soft.

setInvalidateOnChangeback to summary
public void setInvalidateOnChange(boolean invalidateOnChange)

PUBLIC: Configure if any change to any object of the query class should cause the query results to be invalidated.

setInvalidationClassesback to summary
public void setInvalidationClasses(Set<Class<?>> invalidationClasses)

ADVANCED: Set the set of classes that should trigger the query cached results to be invalidated. This is normally computed by the query, but can be set in the case of native queries.

setIsNullIgnoredback to summary
public void setIsNullIgnored(boolean isNullIgnored)

PUBLIC: Set if null results should be cached or ignored. By default they are cached. They can be ignored to allow a query cache to be used as a secondary cache index, and allow new objects to be insert, and still found.

setMaximumCachedResultsback to summary
public void setMaximumCachedResults(int maximumResultSets)

PUBLIC: Set the maximum cached results. This defines the number of query result sets that will be cached. The LRU query results will be discarded when the max size is reached.

useFullCacheback to summary
public void useFullCache()

PUBLIC: Set the type of the cache used for the query results to a FullIdentityMap. This will cache all query results, so caution should be used to avoid running out of memory.

useLRUCacheback to summary
public void useLRUCache()

PUBLIC: Set the type of the cache used for the query results to a CacheIdentityMap. This will uses a fixed size LRU cache. This is the default.

useSoftCacheback to summary
public void useSoftCache()

PUBLIC: Set the type of the cache used for the query results to a SoftIdentityMap. This will cache all query results, unless the JVM believes memory is low.

useSoftLRUCacheback to summary
public void useSoftLRUCache()

PUBLIC: Set the type of the cache used for the query results to a SoftCacheWeakIdentityMap. This will uses a fixed size LRU cache using Soft references, so will allow garbage collection when memory is low.