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.
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...)
EclipseLink JPA
EclipseLink | |
Website | |
Download | |
Community | |
Mailing List • Forums • IRC • mattermost | |
Issues | |
Open • Help Wanted • Bug Day | |
Contribute | |
Browse Source |
Key API
Native API
Contents
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();