Java Reference
In-Depth Information
Chapter 18. Using a Second-Level
Cache with Java
Persistence API Applications
This chapter explains how to modify the second-level cache mode settings to improve the
performance of applications that use the Java Persistence API.
The following topics are addressed here:
• “ Overview of the Second-Level Cache on page 303
• “ Specifying the Cache Mode Settings to Improve Performance on page 305
Overview of the Second-Level Cache
A second-level cache is a local store of entity data managed by the persistence provider
to improve application performance. A second-level cache helps improve performance
by avoiding expensive database calls, keeping the entity data local to the application. A
second-level cache is typically transparent to the application, as it is managed by the per-
sistence provider and underlies the persistence context of an application. That is, the applic-
ation reads and commits data through the normal entity manager operations without know-
ing about the cache.
Note
Persistence providers are not required to support a second-level cache.
Portable applications should not rely on support by persistence providers
for a second-level cache.
The second-level cache for a persistence unit may be configured to one of several second-
level cache modes. The following cache mode settings are defined by the Java Persistence
API.
Search WWH ::




Custom Search