Use @CacheInterceptor
on an entity to intercept all EclipseLink cache access to the entity instead of responding to cache operations through an event.
Table 2-7 describes this annotation's elements.
Table 2-7 @CacheInterceptor Annotation Elements
Annotation Element | Description | Default |
---|---|---|
value |
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 Oracle TopLink 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;
@Entity
@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"/>
...
</entity>
For more information, see:
Understanding Oracle TopLink
Oracle Coherence Integration Guide for Oracle TopLink with Coherence Grid