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)

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

EclipseLink JPA

link="http://wiki.eclipse.org/EclipseLink"
EclipseLink
Website
Download
Community
Mailing ListForumsIRC
Bugzilla
Open
Help Wanted
Bug 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...