Package org.infinispan.query.dsl
Interface Query<T>
An immutable object representing both the query and the result. The result is obtained lazily when one of the methods
in this interface is executed first time. The query is executed only once. Further calls will just return the
previously cached results. If you intend to re-execute the query to obtain fresh data you need to build another
instance using a
QueryBuilder
.- Since:
- 6.0
- Author:
- anistor@redhat.com
-
Method Summary
Modifier and TypeMethodDescriptionexecute()
Executes the query (a SELECT statement).String[]
Deprecated.since 11.0.int
Deprecated.since 10.1.hitCountAccuracy
(int hitCountAccuracy) Limits the required accuracy of the hit count for the indexed queries to an upper-bound.maxResults
(int maxResults) setParameter
(String paramName, Object paramValue) Sets the value of a named parameter.setParameters
(Map<String, Object> paramValues) Sets multiple named parameters at once.startOffset
(long startOffset) Set the timeout for this query.Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface org.infinispan.commons.api.query.Query
entryIterator, entryIterator, executeStatement, getMaxResults, getParameters, getQueryString, getStartOffset, hasProjections, hitCountAccuracy, iterator, list, local, scoreRequired
-
Method Details
-
execute
QueryResult<T> execute()Description copied from interface:Query
Executes the query (a SELECT statement). Subsequent invocations cause the query to be re-executed.Executing a DELETE is also allowed. In this case, no results will be returned, but the number of affected entries will be returned as the hit count in the
QueryResult
.- Specified by:
execute
in interfaceQuery<T>
- Returns:
QueryResult
with the results.
-
getResultSize
Deprecated.since 10.1. This will be removed in 12. It's closest replacement isQueryResult.hitCount()
which returns an optional long.Gets the total number of results matching the query, ignoring pagination (startOffset, maxResults).- Returns:
- total number of results.
-
getProjection
Deprecated.since 11.0. This method will be removed in next major version. To find out if a query uses projections useQuery.hasProjections()
- Returns:
- the values for query projections or
null
if the query does not have projections.
-
startOffset
- Specified by:
startOffset
in interfaceQuery<T>
-
maxResults
- Specified by:
maxResults
in interfaceQuery<T>
-
hitCountAccuracy
Description copied from interface:Query
Limits the required accuracy of the hit count for the indexed queries to an upper-bound. Setting the hit-count-accuracy could improve the performance of queries targeting large data sets.- Specified by:
hitCountAccuracy
in interfaceQuery<T>
- Parameters:
hitCountAccuracy
- The value to apply- Returns:
this
, for method chaining
-
setParameter
Description copied from interface:Query
Sets the value of a named parameter.- Specified by:
setParameter
in interfaceQuery<T>
- Parameters:
paramName
- the parameters name (non-empty and not null)paramValue
- a non-null value- Returns:
- itself
-
setParameters
Description copied from interface:Query
Sets multiple named parameters at once. Parameter names cannot be empty ornull
. Parameter values must not benull
.- Specified by:
setParameters
in interfaceQuery<T>
- Parameters:
paramValues
- a Map of parameters- Returns:
- itself
-
timeout
Description copied from interface:Query
Set the timeout for this query. If the query hasn't finished processing before the timeout, a timeout will be thrown. For queries that use the index, the timeout is handled on a best effort basis, and the supplied time is rounded to the nearest millisecond.
-