Cache
Interface used to interact with the second-level cache. If no second-level cache is in use, the methods of this interface have no effect, except for contains(), which returns false.
- Since:
- JPA 2.0
The Shared (L2) Entity Cache article explains how to use
Cache.Public Methods
boolean contains(Class<?> cls, Object primaryKey)
- Parameters:
cls- entity classprimaryKey- primary key
- Return:
- boolean indicating whether the entity is in the cache
- Since:
- JPA 2.0
void evict(Class<?> cls)
- Parameters:
cls- entity class
- Since:
- JPA 2.0
void evict(Class<?> cls, Object primaryKey)
- Parameters:
cls- entity classprimaryKey- primary key
- Since:
- JPA 2.0
void evictAll()
- Since:
- JPA 2.0
T unwrap(Class<T> cls)
If the provider's implementation of the
Cache interface does not support the specified class, the PersistenceException is thrown. - Parameters:
cls- the class of the object to be returned. This is usually either the underlying class implementing {@code Cache} , or an interface it implements.
- Return:
- an instance of the specified type
- Throws:
- PersistenceException - if the provider does not support the given type
- Since:
- JPA 2.1