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.
org.eclipse.persistence.annotations.CacheType , org.eclipse.persistence.annotations.CacheCoordinationType , org.eclipse.persistence.descriptors.ClassDescriptor , org.eclipse.persistence.descriptors.invalidation.CacheInvalidationPolicy
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public CacheCoordinationType | |
| public DatabaseChangeNotificationType | |
| 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 | |
| public TimeOfDay | |
| public CacheIsolationType | |
| 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 | |
| public CacheType |
| alwaysRefresh | back 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. | |
| coordinationType | back to summary |
|---|---|
| public CacheCoordinationType coordinationType() (Optional) The cache coordination mode. Note that cache coordination must also be configured for the persistence unit/session. | |
| databaseChangeNotificationType | back 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. | |
| disableHits | back 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. | |
| expiry | back 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. | |
| expiryTimeOfDay | back 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. | |
| isolation | back 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. | |
| refreshOnlyIfNewer | back 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. | |
| size | back to summary |
|---|---|
| public int size() (Optional) The size of cache to use. The default is 100. | |
| type | back to summary |
|---|---|
| public CacheType type() (Optional) The type of cache to use. The default is SOFT_WEAK. | |