Top Description Methods
javax.persistence

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 TypeMethod and Description
public boolean

Returns:

boolean indicating whether the entity is in the cache
contains
(Class<T>
entity class
cls
,
Object
primary key
primaryKey
)

Whether the cache contains data for the given entity.

public void
evict(Class<T>
entity class
cls
,
Object
primary key
primaryKey
)

Remove the data for the given entity from the cache.

public void
evict(Class<T>
entity class
cls
)

Remove the data for entities of the specified class (and its subclasses) from the cache.

public void
evictAll()

Clear the cache.

public <T> T

Returns:

an instance of the specified class
unwrap
(Class<T>
the class of the object to be returned. This is normally either the underlying Cache implementation class or an interface that it implements.
cls
)

Return an object of the specified type to allow access to the provider-specific API.

Method Detail

containsback to summary
public boolean contains(Class<T> cls, Object primaryKey)

Whether the cache contains data for the given entity.

Parameters
cls:Class<T>

entity class

primaryKey:Object

primary key

Returns:boolean

boolean indicating whether the entity is in the cache

evictback to summary
public void evict(Class<T> cls, Object primaryKey)

Remove the data for the given entity from the cache.

Parameters
cls:Class<T>

entity class

primaryKey:Object

primary key

evictback to summary
public void evict(Class<T> cls)

Remove the data for entities of the specified class (and its subclasses) from the cache.

Parameters
cls:Class<T>

entity class

evictAllback to summary
public void evictAll()

Clear the cache.

unwrapback to summary
public <T> T unwrap(Class<T> cls)

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:Class<T>

the class of the object to be returned. This is normally either the underlying Cache implementation class or an interface that it implements.

Returns:T

an instance of the specified class

Exceptions
PersistenceException:
if the provider does not support the call
Since
Java Persistence 2.1