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

EclipseLink/UserGuide/JPA/Basic JPA Development/Caching/Cache API

< EclipseLink‎ | UserGuide‎ | JPA‎ | Basic JPA Development‎ | Caching
Revision as of 13:54, 30 May 2012 by James.sutherland.oracle.com (Talk | contribs) (New page: {{EclipseLink_UserGuide |info=y |toc=y |eclipselink=y |eclipselinktype=JPA |api=y |apis= *[http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/config/QueryHints.html Quer...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

EclipseLink JPA

Eclipselink-logo.gif
EclipseLink
Website
Download
Community
Mailing ListForumsIRCmattermost
Issues
OpenHelp WantedBug Day
Contribute
Browse Source

Cache API

The cache can be accessed directly at runtime using the JPA Cache API, or the EclipseLink JpaCache API. The cache API can be used to evict or invalidate objects in the cache, and access the cache directly. These APIs can be used from application services, to invalidate the cache when the application knows that some data has changed, such as the application using direct JDBC, or other application accessing the database, or database event services.

The EclipseLink native API IdentityMapAccessor can also be used to directly access the cache of an EclipseLink Session.

The JPA Cache API includes:

  • contains(Class, Object) - Return if the Id is contained in the cache for the class.
  • evict(Class, Object) - Invalidate the object in the cache for the Id and class.
  • evict(Class) - Invalidate all instances of the class in the cache.
  • evictAll() - Invalidate the entire cache.

The EclipseLink JpaCache API includes:

  • contains(Class, Object) - Return if the Id is contained in the cache for the class.
  • evict(Class, Object) - Invalidate the object in the cache for the Id and class.
  • evict(Class) - Invalidate all instances of the class in the cache.
  • evictAll() - Invalidate the entire cache.
JPA Cache API example
Query query = em.createNamedQuery("findAllEmployeesInCity");
query.setParameter("city", "Ottawa");
List<Employee> employees = query.getResultList();

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

Copyright © Eclipse Foundation, Inc. All Rights Reserved.