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.
- See Also:
- Author:
- Guy Pelletier
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionboolean
Force all queries that go to the database to always refresh the cache.The cache coordination mode.The database change notification mode.boolean
Setting to true will force all queries to bypass the cache for hits but still resolve against the cache for identity.int
Expire cached instance after a fix period of time (ms).Expire cached instance a specific time of day.Controls the level of caching this Entity will use.boolean
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).int
The size of cache to use.The type of cache to use.
-
Element Details
-
type
CacheType typeThe type of cache to use.The default is CacheType.SOFT_WEAK.
- Default:
SOFT_WEAK
-
size
int sizeThe size of cache to use.The default is 100.
- Default:
100
-
isolation
CacheIsolationType isolationControls 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:
- Default:
SHARED
-
expiry
int expiryExpire 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.
- Default:
-1
-
expiryTimeOfDay
TimeOfDay expiryTimeOfDayExpire 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.- Default:
@org.eclipse.persistence.annotations.TimeOfDay(specified=false)
-
alwaysRefresh
boolean alwaysRefreshForce all queries that go to the database to always refresh the cache. Consider disabling the shared cache instead of forcing refreshing.Default is false.
- Default:
false
-
refreshOnlyIfNewer
boolean refreshOnlyIfNewerFor 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 affects explicit refresh calls or queries.Default is false.
- Default:
false
-
disableHits
boolean disableHitsSetting 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.- Default:
false
-
coordinationType
CacheCoordinationType coordinationTypeThe cache coordination mode.Note that cache coordination must also be configured for the persistence unit/session.
- Default:
SEND_OBJECT_CHANGES
-
databaseChangeNotificationType
DatabaseChangeNotificationType databaseChangeNotificationTypeThe database change notification mode.Note that database event listener must also be configured for the persistence unit/session.
- Default:
INVALIDATE
-