Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

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

(disable shared-cache-mode should use NONE)
 
Line 16: Line 16:
 
Or the JPA 2.0 persistence unit element:
 
Or the JPA 2.0 persistence unit element:
 
<source lang="xml">
 
<source lang="xml">
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
+
<shared-cache-mode>NONE</shared-cache-mode>
 
</source>
 
</source>
  

Latest revision as of 00:13, 8 August 2014


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 EclipseLink persistence unit property:

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

Or the JPA 2.0 persistence unit element:

<shared-cache-mode>NONE</shared-cache-mode>


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

@Entity
@Cache(isolation=ISOLATED)
public class Employee {
  ...
}

Or the JPA 2.0 @Cacheable annotation:

@Entity
@Cacheable(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 the Caching section of the EclipseLink JPA User Guide for more information on caching.

Back to the top