Top Description Methods
org.eclipse.persistence.annotations

public @Interface Cache

extends Annotation
Annotations
@Target:TYPE
@Retention:RUNTIME
Static Imports
java.lang.annotation.ElementType.TYPE, .RetentionPolicy.RUNTIME, org.eclipse.persistence.annotations.CacheCoordinationType.SEND_OBJECT_CHANGES, .CacheType.SOFT_WEAK, org.eclipse.persistence.config.CacheIsolationType.SHARED

The Cache annotation is used to configure the EclipseLink object cache. By default EclipseLink uses a shared object cache to cache all objects. The caching type and options can be configured on a per class basis to allow optimal caching.

This includes options for configuring the type of caching, setting the size, disabling the shared cache, expiring objects, refreshing, and cache coordination (clustering).

A Cache annotation may be defined on an Entity or MappedSuperclass. In the case of inheritance, a Cache annotation should only be defined on the root of the inheritance hierarchy.

Author
Guy Pelletier
Since
Oracle TopLink 11.1.1.0.0
See Also
org.eclipse.persistence.annotations.CacheType, org.eclipse.persistence.annotations.CacheCoordinationType, org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.descriptors.invalidation.CacheInvalidationPolicy

Method Summary

Modifier and TypeMethod and Description
public boolean
alwaysRefresh()

(Optional) Force all queries that go to the database to always refresh the cache.

public CacheCoordinationType
coordinationType()

(Optional) The cache coordination mode.

public DatabaseChangeNotificationType
databaseChangeNotificationType()

(Optional) The database change notification mode.

public boolean
disableHits()

(Optional) Setting to true will force all queries to bypass the cache for hits but still resolve against the cache for identity.

public int
expiry()

(Optional) Expire cached instance after a fix period of time (ms).

public TimeOfDay
expiryTimeOfDay()

(Optional) Expire cached instance a specific time of day.

public CacheIsolationType
isolation()

(Optional) Controls the level of caching this Entity will use.

public boolean
refreshOnlyIfNewer()

(Optional) For all queries that go to the database, refresh the cache only 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 int
size()

(Optional) The size of cache to use.

public CacheType
type()

(Optional) The type of cache to use.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

alwaysRefreshback to summary
public boolean alwaysRefresh()

(Optional) Force all queries that go to the database to always refresh the cache. Default is false. Consider disabling the shared cache instead of forcing refreshing.

coordinationTypeback to summary
public CacheCoordinationType coordinationType()

(Optional) The cache coordination mode. Note that cache coordination must also be configured for the persistence unit/session.

databaseChangeNotificationTypeback to summary
public DatabaseChangeNotificationType databaseChangeNotificationType()

(Optional) The database change notification mode. Note that database event listener must also be configured for the persistence unit/session.

disableHitsback to summary
public boolean disableHits()

(Optional) Setting to true will force all queries to bypass the cache for hits but still resolve against the cache for identity. This forces all queries to hit the database.

expiryback to summary
public int expiry()

(Optional) Expire cached instance after a fix period of time (ms). Queries executed against the cache after this will be forced back to the database for a refreshed copy. By default there is no expiry.

expiryTimeOfDayback to summary
public TimeOfDay expiryTimeOfDay()

(Optional) Expire cached instance a specific time of day. Queries executed against the cache after this will be forced back to the database for a refreshed copy.

isolationback to summary
public CacheIsolationType isolation()

(Optional) Controls the level of caching this Entity will use. The default is CacheIsolationType.SHARED which has EclipseLink Caching all Entities in the Shared Cache.

See Also
org.eclipse.persistence.config.CacheIsolationType
refreshOnlyIfNewerback to summary
public boolean refreshOnlyIfNewer()

(Optional) For all queries that go to the database, refresh the cache only 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). This is normally used in conjunction with alwaysRefresh, and by itself it only affect explicit refresh calls or queries. Default is false.

sizeback to summary
public int size()

(Optional) The size of cache to use. The default is 100.

typeback to summary
public CacheType type()

(Optional) The type of cache to use. The default is SOFT_WEAK.