Package org.infinispan.query.dsl.impl
Class BaseQuery<T>
- java.lang.Object
-
- org.infinispan.query.dsl.impl.BaseQuery<T>
-
- All Implemented Interfaces:
Iterable<T>,PaginationContext<Query<T>>,ParameterContext<Query<T>>,Query<T>
public abstract class BaseQuery<T> extends Object implements Query<T>
- Since:
- 7.2
- Author:
- anistor@redhat.com
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanlocalprotected intmaxResultsprotected Map<String,Object>namedParametersprotected String[]projectionprotected QueryFactoryqueryFactoryprotected StringqueryStringprotected intstartOffsetprotected longtimeoutOptional timeout in nanoseconds.
-
Constructor Summary
Constructors Modifier Constructor Description protectedBaseQuery(QueryFactory queryFactory, String queryString)protectedBaseQuery(QueryFactory queryFactory, String queryString, Map<String,Object> namedParameters, String[] projection, long startOffset, int maxResults, boolean local)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <K> org.infinispan.commons.util.CloseableIterator<Map.Entry<K,T>>entryIterator()Returns aCloseableIteratorover the results, including both key and value.intexecuteStatement()Executes a data modifying statement (typically a DELETE) that does not return results; instead it returns an affected entries count.intgetMaxResults()Map<String,Object>getParameters()Returns the named parameters Map.String[]getProjection()StringgetQueryString()Returns the Ickle query string.longgetStartOffset()booleanhasProjections()Indicates if the parsed query has projections (a SELECT clause) and consequently the returned results will actually beObject[]containing the projected values rather than the target entity.booleanisLocal()Query<T>local(boolean local)Set the query execution scopeQuery<T>maxResults(int maxResults)abstract voidresetQuery()Reset internal state after pagination or query parameters are modified.Query<T>setParameter(String paramName, Object paramValue)Sets the value of a named parameter.Query<T>setParameters(Map<String,Object> paramValues)Sets multiple named parameters at once.Query<T>startOffset(long startOffset)Query<T>timeout(long timeout, TimeUnit timeUnit)Set the timeout for this query.voidvalidateNamedParameters()Ensure all named parameters have non-null values.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface org.infinispan.query.dsl.Query
execute, getResultSize, iterator, list
-
-
-
-
Field Detail
-
queryFactory
protected final QueryFactory queryFactory
-
queryString
protected final String queryString
-
projection
protected final String[] projection
-
startOffset
protected int startOffset
-
maxResults
protected int maxResults
-
local
protected boolean local
-
timeout
protected long timeout
Optional timeout in nanoseconds.
-
-
Constructor Detail
-
BaseQuery
protected BaseQuery(QueryFactory queryFactory, String queryString, Map<String,Object> namedParameters, String[] projection, long startOffset, int maxResults, boolean local)
-
BaseQuery
protected BaseQuery(QueryFactory queryFactory, String queryString)
-
-
Method Detail
-
getQueryString
public String getQueryString()
Returns the Ickle query string.- Specified by:
getQueryStringin interfaceQuery<T>- Returns:
- the Ickle query string
-
getParameters
public Map<String,Object> getParameters()
Description copied from interface:QueryReturns the named parameters Map.- Specified by:
getParametersin interfaceParameterContext<T>- Specified by:
getParametersin interfaceQuery<T>- Returns:
- the named parameters (unmodifiable) or
nullif the query does not have parameters
-
setParameter
public Query<T> setParameter(String paramName, Object paramValue)
Description copied from interface:QuerySets the value of a named parameter.- Specified by:
setParameterin interfaceParameterContext<T>- Specified by:
setParameterin interfaceQuery<T>- Parameters:
paramName- the parameters name (non-empty and not null)paramValue- a non-null value- Returns:
- itself
-
setParameters
public Query<T> setParameters(Map<String,Object> paramValues)
Description copied from interface:QuerySets multiple named parameters at once. Parameters names cannot be empty ornull. Parameter values must not benull.- Specified by:
setParametersin interfaceParameterContext<T>- Specified by:
setParametersin interfaceQuery<T>- Parameters:
paramValues- a Map of parameters- Returns:
- itself
-
resetQuery
public abstract void resetQuery()
Reset internal state after pagination or query parameters are modified. This is needed to ensure the next execution of the query uses the new values.
-
validateNamedParameters
public void validateNamedParameters()
Ensure all named parameters have non-null values.
-
getProjection
public String[] getProjection()
- Specified by:
getProjectionin interfaceQuery<T>- Returns:
- the values for query projections or
nullif the query does not have projections.
-
hasProjections
public boolean hasProjections()
Description copied from interface:QueryIndicates if the parsed query has projections (a SELECT clause) and consequently the returned results will actually beObject[]containing the projected values rather than the target entity.- Specified by:
hasProjectionsin interfaceQuery<T>- Returns:
trueif it has projections,falseotherwise.
-
getStartOffset
public long getStartOffset()
- Specified by:
getStartOffsetin interfaceQuery<T>
-
getMaxResults
public int getMaxResults()
- Specified by:
getMaxResultsin interfaceQuery<T>
-
startOffset
public Query<T> startOffset(long startOffset)
- Specified by:
startOffsetin interfacePaginationContext<T>- Specified by:
startOffsetin interfaceQuery<T>
-
maxResults
public Query<T> maxResults(int maxResults)
- Specified by:
maxResultsin interfacePaginationContext<T>- Specified by:
maxResultsin interfaceQuery<T>
-
local
public Query<T> local(boolean local)
Description copied from interface:QuerySet the query execution scope
-
isLocal
public boolean isLocal()
-
timeout
public Query<T> timeout(long timeout, TimeUnit timeUnit)
Description copied from interface:QuerySet the timeout for this query. If the query hasn't finished processing before the timeout, aSearchTimeoutExceptionwill 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.
-
entryIterator
public <K> org.infinispan.commons.util.CloseableIterator<Map.Entry<K,T>> entryIterator()
Description copied from interface:QueryReturns aCloseableIteratorover the results, including both key and value. Please close the iterator when you are done with processing the results. The query cannot use projections.- Specified by:
entryIteratorin interfaceQuery<T>- Returns:
- the results of the query as an iterator.
-
executeStatement
public int executeStatement()
Description copied from interface:QueryExecutes a data modifying statement (typically a DELETE) that does not return results; instead it returns an affected entries count. This method cannot be used to execute a SELECT.NOTE: Paging params (firstResult/maxResults) are NOT allowed.
- Specified by:
executeStatementin interfaceQuery<T>- Returns:
- the number of affected (deleted) entries
-
-