Top Description Methods
org.eclipse.persistence.jpa

public Interface JpaCache

extends Cache
Known Direct Implementers
org.eclipse.persistence.internal.jpa.CacheImpl
Imports
jakarta.persistence.Cache

Extends JPA Cache interface with additional EclipseLink API.
Author
James Sutherland

Method Summary

Modifier and TypeMethod and Description
public void
clear()

ADVANCED: Resets the entire Object cache, and the Query cache.

public void
clear(Class<?> cls)

ADVANCED: Resets the cache for only the instances of the given Class type.

public void
clearQueryCache()

Clear all the query results caches.

public void
clearQueryCache(String queryName)

Clear the named query results cache associated with the query name.

public void
clearQueryCache(Class<?> entityClass)

Clear all named query results cache associated with entity class.

public boolean
contains(Object object)

Returns true if the cache contains an Object with the same id and Class type of the given object.

public void
evict(Object object)

Sets an Object to be invalid in the cache.

public void
evict(Object object, boolean invalidateInCluster)

Sets an Object to be invalid in the cache.

public void
evict(Class<?> classToEvict, Object id, boolean invalidateInCluster)

Sets the object of the class and id to be invalid in the cache.

public Object
getId(Object object)

Returns the object's Id.

public Object
getObject(Class<?> cls, Object id)

Returns the Object from the cache map with the id and Class type.

public boolean
isValid(Object object)

Returns true if the Object with the same id and Class type of the the given Object is valid in the cache.

public boolean
isValid(Class<?> cls, Object id)

Returns true if the Object with the id and Class type is valid in the cache.

public void
printLocks()

Used to print all the currently locked cache keys in the cache.

public Object
putObject(Object object)

ADVANCED: Puts the given Object into the cache.

public Object
removeObject(Object object)

ADVANCED: Removes the Object from the cache.

public Object
removeObject(Class<?> cls, Object id)

ADVANCED: Removes the Object with the id and Class type from the cache.

public long
timeToLive(Object object)

Returns the remaining life of the given Object (in milliseconds).

public void
validate()

This can be used to help debugging an Object identity problem.

Inherited from jakarta.persistence.Cache:
containsevictevictevictAllunwrap

Method Detail

clearback to summary
public void clear()

ADVANCED: Resets the entire Object cache, and the Query cache.

Note

Be careful using this method. This method blows away both this session's and its parent's caches. This includes the server cache or any other cache. This throws away any Objects that have been read in. Extreme caution should be used before doing this because Object identity will no longer be maintained for any Objects currently read in. This should only be called if the application knows that it no longer has references to Objects held in the cache.

clearback to summary
public void clear(Class<?> cls)

ADVANCED: Resets the cache for only the instances of the given Class type. For inheritance the user must make sure that they only use the root class, clearing a subclass cache is not allowed (as they share their parents cache).

Note

Caution must be used in doing this to ensure that the Objects within the cache are not referenced from other Objects of other classes or from the application.

clearQueryCacheback to summary
public void clearQueryCache()

Clear all the query results caches.

clearQueryCacheback to summary
public void clearQueryCache(String queryName)

Clear the named query results cache associated with the query name.

clearQueryCacheback to summary
public void clearQueryCache(Class<?> entityClass)

Clear all named query results cache associated with entity class.

containsback to summary
public boolean contains(Object object)

Returns true if the cache contains an Object with the same id and Class type of the given object.

evictback to summary
public void evict(Object object)

Sets an Object to be invalid in the cache.

evictback to summary
public void evict(Object object, boolean invalidateInCluster)

Sets an Object to be invalid in the cache. If true is passed, the object is also invalidated across cache coordination. Cache coordination must be enabled for this to have an affect.

evictback to summary
public void evict(Class<?> classToEvict, Object id, boolean invalidateInCluster)

Sets the object of the class and id to be invalid in the cache. If true is passed, the object is also invalidated across cache coordination. Cache coordination must be enabled for this to have an affect.

getIdback to summary
public Object getId(Object object)

Returns the object's Id.

getObjectback to summary
public Object getObject(Class<?> cls, Object id)

Returns the Object from the cache map with the id and Class type.

isValidback to summary
public boolean isValid(Object object)

Returns true if the Object with the same id and Class type of the the given Object is valid in the cache.

isValidback to summary
public boolean isValid(Class<?> cls, Object id)

Returns true if the Object with the id and Class type is valid in the cache.

printLocksback to summary
public void printLocks()

Used to print all the currently locked cache keys in the cache. The output of this method will be logged to this persistence unit's SessionLog at SEVERE level.

putObjectback to summary
public Object putObject(Object object)

ADVANCED: Puts the given Object into the cache. This is a very advanced method, and caution should be used in adding objects to the cache as other objects may have relationships to previous object, or this object may have relationships to other objects.

removeObjectback to summary
public Object removeObject(Object object)

ADVANCED: Removes the Object from the cache.

Note

Caution should be used when calling to avoid violating Object identity. The application should only call this if its known that no references to the Object exist.

removeObjectback to summary
public Object removeObject(Class<?> cls, Object id)

ADVANCED: Removes the Object with the id and Class type from the cache.

Note

Caution should be used when calling to avoid violating Object identity. The application should only call this if its known that no references to the Object exist.

timeToLiveback to summary
public long timeToLive(Object object)

Returns the remaining life of the given Object (in milliseconds). This method is associated with use of cache invalidation feature and returns the difference between the next expiry time of the Object and its read time. The method will return 0 for invalidated Objects.

validateback to summary
public void validate()

This can be used to help debugging an Object identity problem. An Object identity problem is when an Object in the cache references an Object that is not in the cache. This method will validate that all cached Objects are in a correct state.