Package org.xwiki.query
Interface Query
-
- All Known Subinterfaces:
SecureQuery
- All Known Implementing Classes:
WrappingQuery
public interface Query
This is a Query interface, representing all queries in various languages for various stores.Note that it was modeled after the JCR Query interface.
- Since:
- 1.6M1
- Version:
- $Id: 9c104e1d31f17abb4e52d8d890aa4b523f97cf5c $
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Query
addFilter(QueryFilter filter)
Query
bindValue(int index, Object val)
Bind a positional parameter present in the statement (?index in XWQL) with a value.default QueryParameter
bindValue(String var)
Bind named parameter var with a value that will be constructed using calls toQueryParameter.literal(String)
,QueryParameter.anychar()
andQueryParameter.anyChars()
.Query
bindValue(String var, Object val)
Bind named parameter var with value val in query statement.Query
bindValues(List<Object> values)
Bind a list of positional parameters values.default Query
bindValues(Map<String,?> values)
Bind a map of named parameters values.<T> List<T>
execute()
List<QueryFilter>
getFilters()
String
getLanguage()
int
getLimit()
Map<String,Object>
getNamedParameters()
int
getOffset()
Map<Integer,Object>
getPositionalParameters()
String
getStatement()
String
getWiki()
boolean
isNamed()
if the query is named, thengetStatement()
returns a name of the query, else - a query statement.Query
setLimit(int limit)
Query
setOffset(int offset)
Query
setWiki(String wiki)
-
-
-
Field Detail
-
HQL
static final String HQL
Indicator for Hibernate Query Language.- See Also:
- Constant Field Values
-
XPATH
static final String XPATH
Indicator for XPath language.- See Also:
- Constant Field Values
-
XWQL
static final String XWQL
Indicator for XWiki Query Language.- See Also:
- Constant Field Values
-
-
Method Detail
-
isNamed
boolean isNamed()
if the query is named, thengetStatement()
returns a name of the query, else - a query statement.- Returns:
- is the query named.
-
setWiki
Query setWiki(String wiki)
- Parameters:
wiki
- virtual wiki to run the query. null is a current wiki.- Returns:
- this query
-
getWiki
String getWiki()
- Returns:
- virtual wiki to run the query. null is a current wiki.
- See Also:
setWiki(String)
-
bindValue
Query bindValue(String var, Object val)
Bind named parameter var with value val in query statement.- Parameters:
var
- variable in query statement (:var).val
- value of the variable.- Returns:
- this query
-
bindValue
Query bindValue(int index, Object val)
Bind a positional parameter present in the statement (?index in XWQL) with a value. It is recommended to use named parameters if it acceptable, seebindValue(String, Object)
.- Parameters:
index
- index of positional parameter. Index starting number depends on the query language. According to the JPQL standard index should start from 1.val
- value of the variable.- Returns:
- this query
-
bindValues
Query bindValues(List<Object> values)
Bind a list of positional parameters values. This method is a convenience method allowing passing a list of values in one call instead of multiple calls tobindValue(int, Object)
.- Parameters:
values
- list of positional parameters values.- Returns:
- this query
- See Also:
bindValue(int, Object)
-
bindValues
default Query bindValues(Map<String,?> values)
Bind a map of named parameters values. This method is a convenience method allowing passing a map of values in one call instead of multiple calls tobindValue(String, Object)
.- Parameters:
values
- list of positional parameters values.- Returns:
- this query
- Since:
- 11.5RC1
- See Also:
bindValue(String, Object)
-
bindValue
default QueryParameter bindValue(String var)
Bind named parameter var with a value that will be constructed using calls toQueryParameter.literal(String)
,QueryParameter.anychar()
andQueryParameter.anyChars()
. In order to perserve the fluent API, it's also possible to callQueryParameter.query()
to get back theQuery
.- Parameters:
var
- the variable in the query statement (:var
).- Returns:
- an empty
QueryParameter
that needs to be populated by callingQueryParameter.literal(String)
,QueryParameter.anychar()
andQueryParameter.anyChars()
- Since:
- 8.4.5, 9.3RC1
-
getNamedParameters
Map<String,Object> getNamedParameters()
- Returns:
- map from parameter name to value.
- See Also:
bindValue(String, Object)
-
getPositionalParameters
Map<Integer,Object> getPositionalParameters()
- Returns:
- list of positional parameters values.
- See Also:
bindValue(int, Object)
-
addFilter
Query addFilter(QueryFilter filter)
- Parameters:
filter
- theQueryFilter
to add to this query- Returns:
- this query
-
getFilters
List<QueryFilter> getFilters()
- Returns:
- the list of
QueryFilter
s that will be applied to this query
-
setLimit
Query setLimit(int limit)
- Parameters:
limit
- seegetLimit()
- Returns:
- this query
-
setOffset
Query setOffset(int offset)
- Parameters:
offset
- offset of query result to set (skip first "offset" rows)- Returns:
- this query
-
getLimit
int getLimit()
- Returns:
- limit the limit of result list to set (
execute().size() <= limit
) - See Also:
setLimit(int)
-
getOffset
int getOffset()
- Returns:
- offset offset of query result.
- See Also:
setOffset(int)
-
execute
<T> List<T> execute() throws QueryException
- Type Parameters:
T
- expected type of elements in the result list.- Returns:
- result list of the query. If several fields are selected then T=Object[].
- Throws:
QueryException
- if something goes wrong.
-
-