JPA Query Hint Usage:
query.setHint(QueryHints.CACHE_USAGE, CacheUsage.CheckCacheOnly);
or
@QueryHint(name=QueryHints.CACHE_USAGE, value=CacheUsage.CheckCacheOnly)
Hint values are case-insensitive. "" could be used instead of default value CacheUsage.DEFAULT.
QueryHints
| Modifier and Type | Field and Description |
|---|---|
| public static final String | CheckCacheByExactPrimaryKey
Configure the cache to be checked first if the query is by primary key (only). |
| public static final String | CheckCacheByPrimaryKey
Configure the cache to be checked first if the query contains the primary key. |
| public static final String | CheckCacheOnly
Configure the cache to be searched for any matching objects. |
| public static final String | CheckCacheThenDatabase
Configure the cache to be searched for any matching object before accesing the database. |
| public static final String | ConformResultsInUnitOfWork
Configure the query results to be conformed with the current persistence context. |
| public static final String | |
| public static final String | DoNotCheckCache
Do not check the cache first, this is the default for JPA Queries. |
| public static final String | Invalidate
Configures a modify-all query to invalidate the cache. |
| public static final String | NoCache
Configures a modify-all query to not invalidate the cache. |
| public static final String | UseEntityDefault
By default the descriptor default is used, which is to not check the cache first. |
| Access | Constructor and Description |
|---|---|
| public |
| CheckCacheByExactPrimaryKey | back to summary |
|---|---|
| public static final String CheckCacheByExactPrimaryKey Configure the cache to be checked first if the query is by primary key (only). This can only be used on queries that return a single entity. | |
| CheckCacheByPrimaryKey | back to summary |
|---|---|
| public static final String CheckCacheByPrimaryKey Configure the cache to be checked first if the query contains the primary key. This can only be used on queries that return a single entity. | |
| CheckCacheOnly | back to summary |
|---|---|
| public static final String CheckCacheOnly Configure the cache to be searched for any matching objects. Any objects not currently in the cache will not be returned. This can only be used on queries that return a single set of entities. | |
| CheckCacheThenDatabase | back to summary |
|---|---|
| public static final String CheckCacheThenDatabase Configure the cache to be searched for any matching object before accesing the database. This can only be used on queries that return a single entity. | |
| ConformResultsInUnitOfWork | back to summary |
|---|---|
| public static final String ConformResultsInUnitOfWork Configure the query results to be conformed with the current persistence context. This allows non-flushed changes to be included in the query. This can only be used on queries that return a single set of entities. | |
| DEFAULT | back to summary |
|---|---|
| public static final String DEFAULT | |
| DoNotCheckCache | back to summary |
|---|---|
| public static final String DoNotCheckCache Do not check the cache first, this is the default for JPA Queries. | |
| Invalidate | back to summary |
|---|---|
| public static final String Invalidate Configures a modify-all query to invalidate the cache. | |
| NoCache | back to summary |
|---|---|
| public static final String NoCache Configures a modify-all query to not invalidate the cache. | |
| UseEntityDefault | back to summary |
|---|---|
| public static final String UseEntityDefault By default the descriptor default is used, which is to not check the cache first. | |
| CacheUsage | back to summary |
|---|---|
| public CacheUsage() | |