Package javax.persistence
Interface Cache
public 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:
- Java Persistence 2.0
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Whether the cache contains data for the given entity.void
Remove the data for entities of the specified class (and its subclasses) from the cache.void
Remove the data for the given entity from the cache.void
evictAll()
Clear the cache.<T> T
Return an object of the specified type to allow access to the provider-specific API.
-
Method Details
-
contains
Whether the cache contains data for the given entity.- Parameters:
cls
- entity classprimaryKey
- primary key- Returns:
- boolean indicating whether the entity is in the cache
-
evict
Remove the data for the given entity from the cache.- Parameters:
cls
- entity classprimaryKey
- primary key
-
evict
Remove the data for entities of the specified class (and its subclasses) from the cache.- Parameters:
cls
- entity class
-
evictAll
void evictAll()Clear the cache. -
unwrap
Return an object of the specified type to allow access to the provider-specific API. If the provider's Cache implementation does not support the specified class, the PersistenceException is thrown.- Parameters:
cls
- the class of the object to be returned. This is normally either the underlying Cache implementation class or an interface that it implements.- Returns:
- an instance of the specified class
- Throws:
PersistenceException
- if the provider does not support the call- Since:
- Java Persistence 2.1
-