Top Description Methods
org.hibernate.cache.spi

public Interface QueryResultsCache

Known Direct Implementers
org.hibernate.cache.internal.QueryResultsCacheImpl
Imports
java.util.List, .Set, org.hibernate.HibernateException, org.hibernate.cache.CacheException, org.hibernate.engine.spi.SharedSessionContractImplementor

Responsible for managing query result list caching in a specific query cache region. There may be multiple instances of QueryResultsCache, corresponding to second-level cache regions with distinct policies.

A QueryResultsCache depends on the TimestampsCache to track invalidation of the query spaces (tables) which affect the cached queries. A cached query result list is considered stale if any one of the query spaces which affect the query results was invalidated since the result list was read from the database and stored in the query result cache.

Authors
Gavin King, Steve Ebersole

Method Summary

Modifier and TypeMethod and Description
public default void
clear()

Clear all items from this query result cache.

public default void
public List<?>

Returns:

The cached results; may be null if there are no cached results for the given key, or if the results are stale.
get
(QueryKey
The cache key uniquely identifying the query and its bound parameter arguments
key
,
Set<String>
The query spaces which affect the results of the query (used to check if cached results are stale)
spaces
,
SharedSessionContractImplementor
The originating session
session
)

Attempt to retrieve a cached query result list for the given QueryKey from the cache region, and then check if the cached results, if any, are stale.

public List<?>

Returns:

The cached results; may be null.
get
(QueryKey
The cache key uniquely identifying the query and its bound parameter arguments
key
,
String[]
The query spaces which affect the results of the query (used to check if cached results are stale)
spaces
,
SharedSessionContractImplementor
The originating session
session
)

Attempt to retrieve a cached query result list for the given QueryKey from the cache region, and then check if the cached results, if any, are stale.

public QueryResultsRegion
getRegion()

The underlying cache region being used.

public boolean

Returns:

Whether the put actually happened.
put
(QueryKey
The cache key uniquely identifying the query and its bound parameter arguments
key
,
List<?>
The result list to cache
result
,
SharedSessionContractImplementor
The originating session
session
)

Store a result list of a query with the given QueryKey in the query result cache.

Method Detail

clearback to summary
public default void clear() throws CacheException

Clear all items from this query result cache.

Exceptions
CacheException:
Indicates a problem delegating to the underlying cache.
destroyback to summary
public default void destroy()
getback to summary
public List<?> get(QueryKey key, Set<String> spaces, SharedSessionContractImplementor session) throws HibernateException

Attempt to retrieve a cached query result list for the given QueryKey from the cache region, and then check if the cached results, if any, are stale. If there is no cached result list for the given key, or if the cached results are stale, return null.

Parameters
key:QueryKey

The cache key uniquely identifying the query and its bound parameter arguments

spaces:Set<String>

The query spaces which affect the results of the query (used to check if cached results are stale)

session:SharedSessionContractImplementor

The originating session

Returns:List<?>

The cached results; may be null if there are no cached results for the given key, or if the results are stale.

Exceptions
HibernateException:
Indicates a problem delegating to the underlying cache.
getback to summary
public List<?> get(QueryKey key, String[] spaces, SharedSessionContractImplementor session) throws HibernateException

Attempt to retrieve a cached query result list for the given QueryKey from the cache region, and then check if the cached results, if any, are stale. If there is no cached result list for the given key, or if the cached results are stale, return null.

Parameters
key:QueryKey

The cache key uniquely identifying the query and its bound parameter arguments

spaces:String[]

The query spaces which affect the results of the query (used to check if cached results are stale)

session:SharedSessionContractImplementor

The originating session

Returns:List<?>

The cached results; may be null.

Exceptions
HibernateException:
Indicates a problem delegating to the underlying cache.
getRegionback to summary
public QueryResultsRegion getRegion()

The underlying cache region being used.

putback to summary
public boolean put(QueryKey key, List<?> result, SharedSessionContractImplementor session) throws HibernateException

Store a result list of a query with the given QueryKey in the query result cache.

Parameters
key:QueryKey

The cache key uniquely identifying the query and its bound parameter arguments

result:List<?>

The result list to cache

session:SharedSessionContractImplementor

The originating session

Returns:boolean

Whether the put actually happened.

Exceptions
HibernateException:
Indicates a problem delegating to the underlying cache.