Java Persistence API (JPA) Extensions Reference for EclipseLink, Release 2.4
  Go To Table Of Contents


Use @CacheInterceptor on an entity to intercept all EclipseLink cache access to the entity instead of responding to cache operations through an event.

Annotation Elements

Table 2-7 describes this annotation's elements.

Table 2-7 @CacheInterceptor Annotation Elements

Annotation Element Description Default


The class to be used to intercept EclipseLink's cache access.


Once set, the specified class will receive all caching calls. Existing EclipseLink cache settings will continue to be used, any calls allowed to continue to the EclipseLink cache will execute against the configured cache.

When using with an entity in inheritance, you should define the @CacheInterceptor on the root of the inheritance hierarchy.


Example 2-16 shows how to integrate an external cache with EclipseLink.

Example 2-16 Using @CacheInterceptor Annotation

In this example, the Employee class intercepts all EclipseLink calls to the internal EclipseLink cache and redirects them to the Oracle Coherence Grid cache (CoherenceInterceptor).

import oracle.eclipselink.coherence.integrated.cache.CoherenceInterceptor;
import org.eclipse.persistence.annotations.Customizer;
@CacheInterceptor(value = CoherenceInterceptor.class)
public class Employee {

Example 2-17 shows an example of using the <cache-interceptor> XML element in the eclipselink-orm.xml file.

Example 2-17 Using <cache-interceptor> XML

<entity class="Employee">
    <cache-interceptor class="CoherenceInterceptor"/>

See Also

For more information, see: