Jump to: navigation, search

Difference between revisions of "EclipseLink/FAQ/How to disable the shared cache?"

Line 1: Line 1:
[[Category:EclipseLink FAQ]]
+
[[Category:EclipseLink FAQ|How to disable the shared cache]]
  
 
By default EclipseLink enables a shared object cache to cache objects read from the database to avoid repeated database access.  If the database is changed directly through JDBC, or by another application or server, the objects in the shared cache will be stale.
 
By default EclipseLink enables a shared object cache to cache objects read from the database to avoid repeated database access.  If the database is changed directly through JDBC, or by another application or server, the objects in the shared cache will be stale.

Revision as of 13:37, 14 June 2010


By default EclipseLink enables a shared object cache to cache objects read from the database to avoid repeated database access. If the database is changed directly through JDBC, or by another application or server, the objects in the shared cache will be stale.

EclipseLink offers several mechanism to deal with stale data including:

  • Refreshing
  • Invalidation
  • Optimistic locking
  • Cache coordination

The shared cache can also be disabled. This can be done using the persistence unit property:

<property name="eclipselink.cache.shared.default" value="false"/>

Or can be selectively enabled/disabled using the @Cache annotation.

@Entity
@Cache(shared=false)
public class Employee {
  ...
}

Do not disable the cache by setting the CacheType to None, this can cause object identity issues.

See, Caching Example and Introduction to Cache for more information on caching.