141 words

javax.persistence.Cache - JPA interface

javax.persistence
Interface Cache

Interface used to interact with the second-level cache. If a cache is not in use, the methods of this interface have no effect, except for contains, which returns false.
Since:
JPA 2.0
Learn how to use Cache in Chapter 3 of the ObjectDB/JPA manual.
boolean contains(Class cls, Object primaryKey)
Whether the cache contains data for the given entity.
Whether the cache contains data for the given entity.
Parameters:
cls - entity class
primaryKey - primary key
Returns:
boolean indicating whether the entity is in the cache
Since:
JPA 2.0
void evict(Class cls)
Remove the data for entities of the specified class (and its subclasses) from the cache.
Remove the data for entities of the specified class (and its subclasses) from the cache.
Parameters:
cls - entity class
Since:
JPA 2.0
void evict(Class cls, Object primaryKey)
Remove the data for the given entity from the cache.
Remove the data for the given entity from the cache.
Parameters:
cls - entity class
primaryKey - primary key
Since:
JPA 2.0
void evictAll()
Clear the cache.
Clear the cache.
Since:
JPA 2.0

This documentation page is derived (with some adjustments) from the open source JPA 2 RI (EclipseLink)
and is available under the terms of the Eclipse Public License, v. 1.0 and Eclipse Distribution License, v. 1.0.
Object Relational Mapping (ORM) JPA 2 providers include Hibernate, EclipseLink, TopLink, OpenJPA and DataNucleus.
Object DB is not an ORM JPA implementation but an Object Database for Java with built in JPA 2 support.