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/UserGuide/JPA/Basic JPA Development/Caching"

m (EclipseLink JPA Extensions for Entity Caching)
m
 
(23 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{EclipseLink_UserGuide|info=y
+
----
|examples=y
+
|example=
+
*[[EclipseLink/Examples/JPA/Caching|Caching]]
+
}}
+
=Caching=
+
The EclipseLink cache is an in-memory repository that stores recently read or written objects based on class and primary key values. EclipseLink uses the cache to do the following:
+
  
* Improve performance by holding recently read or written objects and accessing them in-memory to minimize database access.
 
* Manage locking and isolation level.
 
* Manage object identity.
 
  
For more information about the EclipseLink cache and its default behavior, see [[Introduction%20to%20Cache%20(ELUG)|Introduction to Cache]].
+
'''[[Image:Elug_draft_icon.png|Warning]] This page is obsolete. Please see "Understanding Caching" in the ''[http://www.eclipse.org/eclipselink/documentation/ Understanding EclipseLink (Concepts Guide)]'' for current information.'''
  
EclipseLink defines the following entity caching annotations:
 
  
* <tt>[[#How to Use the @Cache Annotation|@Cache]]</tt>
+
----
* <tt>[[#How to Use the @TimeOfDay Annotation|@TimeOfDay]]</tt>
+
* <tt>[[#How to Use the @ExistenceChecking Annotation|@ExistenceChecking]]</tt>
+
  
EclipseLink also provides a number of persistence unit properties that you can specify to configure the EclipseLink cache (see [[#How to Use the Persistence Unit Properties for Caching|How to Use the Persistence Unit Properties for Caching]]). These properties may compliment or provide an alternative to the usage of annotations.
 
  
For more information, see the following:
+
{{EclipseLink_UserGuide|info=y
* [[#What You May Need to Know About Overriding Annotations in JPA|What You May Need to Know About Overriding Annotations in JPA]]  
+
|examples=y
* [[#What You May Need to Know About Using EclipseLink JPA Persistence Unit Properties|What You May Need to Know About Using EclipseLink JPA Persistence Unit Properties]]
+
|example=
 
+
*[[EclipseLink/Examples/JPA/Caching|How to use caching]]
==EclipseLink JPA Extensions for Entity Caching==
+
*[[EclipseLink/Examples/JPA/CacheCoordination|How to enable cache coordination]]
You may define the <tt>@Cache</tt> annotation on the following:
+
*[[EclipseLink/Examples/JPA/DCN|How to use database event driven cache invalidation]]}}
* <tt>@Entity</tt>
+
=Caching=
* <tt>@MappedSuperclass</tt>;
+
EclipseLink offers a highly performant, robust and functional object cache.  Caching is provided at both the persistence context level (L1), and a shared cache at the persistence unit level (L2).  
* the root of the inheritance hierarchy (if applicable).<br>
+
Caching is discussed in the following topics:
 
+
If you define the <tt>@Cache</tt> annotation on an inheritance subclass, the annotation will be ignored. If you define the <tt>@Cache</tt> annotation on <tt>@Embeddable</tt> EclipseLink will throw an exception.
+
  
'''''Example of @Cache Annotation '''''
+
*[[EclipseLink/UserGuide/JPA/Basic JPA Development/Caching/Caching Overview|Caching Overview]]
<source lang="java">
+
*[[EclipseLink/UserGuide/JPA/Basic JPA Development/Caching/Configuring|Configuring Caching]]
...
+
*[[EclipseLink/UserGuide/JPA/Basic JPA Development/Caching/Shared and Isolated|Shared, Isolated, Protected, Weak, and Read-only Cache]]
@Entity
+
*[[EclipseLink/UserGuide/JPA/Basic JPA Development/Caching/Type and Size|Cache Type and Size]]
@Cache(
+
*[[EclipseLink/UserGuide/JPA/Basic JPA Development/Caching/Expiration|Cache Expiration and Invalidation]]
  type=CacheType.SOFT, // Cache everything until the JVM decides memory is low.
+
*[[EclipseLink/UserGuide/JPA/Basic JPA Development/Caching/Coordination|Clustering and Cache Coordination]]
  size=64000  // Use 64,000 as the initial cache size.
+
*[[EclipseLink/UserGuide/JPA/Basic JPA Development/Caching/DatabaseEvents|Database Event Notification and Oracle DCN/QCN]]
  expiry=36000000,  // 10 minutes
+
*[[EclipseLink/UserGuide/JPA/Basic JPA Development/Caching/Indexes|Cache Indexes]]
  coordinationType=CacheCoordinationType.INVALIDATE_CHANGED_OBJECTS  // if cache coordination is used, only send invalidation messages.
+
*[[EclipseLink/UserGuide/JPA/Basic JPA Development/Caching/Query Cache|Query Results Cache]]
)
+
*[[EclipseLink/UserGuide/JPA/Basic JPA Development/Caching/Query Options|Query Cache Options and In-memory Querying]]
public class Employee {
+
*[[EclipseLink/UserGuide/JPA/Basic JPA Development/Caching/Cache API|Cache API]]
  ...
+
*[[EclipseLink/UserGuide/JPA/Basic JPA Development/Caching/Interceptors|Cache Interceptors and External Caches]]
}
+
</source>
+
  
  
 
{{EclipseLink_JPA
 
{{EclipseLink_JPA
 
|previous= [[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Locking/Optimistic Locking|Optimistic Locking]]
 
|previous= [[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Mapping/Locking/Optimistic Locking|Optimistic Locking]]
|next=[[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Caching/Shared and Isolated|Shared and Isolated]]
+
|up=[[EclipseLink/UserGuide/JPA/Basic_JPA_Development|Basic JPA Development]]
|up=[[EclipseLink/UserGuide/JPA/Basic_JPA_Development|Basic JPA Development]]}}
+
|next=[[EclipseLink/UserGuide/JPA/Basic_JPA_Development/Caching/Caching Overview|Caching Overview]]
 +
|version=2.4 DRAFT}}

Latest revision as of 13:50, 5 February 2013



Warning This page is obsolete. Please see "Understanding Caching" in the Understanding EclipseLink (Concepts Guide) for current information.





Caching

EclipseLink offers a highly performant, robust and functional object cache. Caching is provided at both the persistence context level (L1), and a shared cache at the persistence unit level (L2). Caching is discussed in the following topics:


Eclipselink-logo.gif
Version: 2.4 DRAFT
Other versions...

Back to the top