public interface IdentityQuery<T extends IdentityType>
An IdentityQuery
is responsible for querying the underlying identity stores for instances of
a given IdentityType
.
Instances of this class are obtained using the IdentityQueryBuilder.createIdentityQuery(Class)
method.
IdentityManager identityManager = getIdentityManager(); // here we get the query builder IdentityQueryBuilder builder = identityManager.getQueryBuilder(); // create a condition Condition condition = builder.equal(User.LOGIN_NAME, "john"); // create a query for a specific identity type using the previously created condition IdentityQuery query = builder.createIdentityQuery(User.class).where(condition); // execute the query Listresult = query.getResultList();
When preparing a query you may want to create conditions to filter its results and configure how they must be retrieved.
For that, you can use the IdentityQueryBuilder
, which provides useful methods for creating
different expressions and conditions.
Modifier and Type | Method and Description |
---|---|
Set<Condition> |
getConditions()
Returns a set containing all conditions used by this query to filter its results.
|
Class<T> |
getIdentityType()
The type used to create this query.
|
int |
getLimit()
Returns the number of instances to retrieve.
|
int |
getOffset() |
Object |
getPaginationContext() |
Object[] |
getParameter(QueryParameter queryParameter)
Deprecated.
|
Map<QueryParameter,Object[]> |
getParameters()
Deprecated.
Use
getConditions() instead. Will be removed. |
Map<QueryParameter,Object[]> |
getParameters(Class<?> type)
Deprecated.
|
int |
getResultCount()
Count of all query results.
|
List<T> |
getResultList()
Execute the query against the underlying identity stores and returns a list containing all instances of
the type (defined when creating this query instance) that match the conditions previously specified.
|
Set<Sort> |
getSorting()
Returns a set containing all sorting conditions used to filter the results.
|
QueryParameter[] |
getSortParameters()
Deprecated.
Will be removed soon.
|
boolean |
isSortAscending()
Deprecated.
Use
getSorting() for a list of sorting conditions. Will be removed soon. |
IdentityQuery<T> |
setLimit(int limit)
Set the maximum number of results to retrieve.
|
IdentityQuery<T> |
setOffset(int offset)
Set the position of the first result to retrieve.
|
IdentityQuery<T> |
setPaginationContext(Object object)
Used for pagination models like LDAP when search will return some object (like cookie) for searching on next page
|
IdentityQuery<T> |
setParameter(QueryParameter param,
Object... value)
Deprecated.
Use
where(Condition...) to specify query conditions. |
IdentityQuery<T> |
setSortAscending(boolean sortAscending)
Deprecated.
Use
sortBy(Sort...) instead. Where you can create sort conditions
from the IdentityQueryBuilder . |
IdentityQuery<T> |
setSortParameters(QueryParameter... sortParameters)
Deprecated.
Use
sortBy(Sort...) instead. Where you can create sort conditions
from the IdentityQueryBuilder . |
IdentityQuery<T> |
sortBy(Sort... sorts)
Add to this query the sorting conditions to be applied to the results.
|
IdentityQuery<T> |
where(Condition... condition)
Add to this query the conditions that will be used to filter results.
|
Object getPaginationContext()
setPaginationContext(Object object)
IdentityQuery<T> setPaginationContext(Object object)
object
- to be used for search next page@Deprecated QueryParameter[] getSortParameters()
setSortParameters(QueryParameter...)
@Deprecated IdentityQuery<T> setSortParameters(QueryParameter... sortParameters)
sortBy(Sort...)
instead. Where you can create sort conditions
from the IdentityQueryBuilder
.sortParameters
- parameters to specify sort criteria@Deprecated boolean isSortAscending()
getSorting()
for a list of sorting conditions. Will be removed soon.setSortAscending(boolean)
@Deprecated IdentityQuery<T> setSortAscending(boolean sortAscending)
sortBy(Sort...)
instead. Where you can create sort conditions
from the IdentityQueryBuilder
.sortAscending
- to specify if sorting will be ascending or descending@Deprecated IdentityQuery<T> setParameter(QueryParameter param, Object... value)
where(Condition...)
to specify query conditions.Set a query parameter to this query in order to filter the results.
This method always create an equality condition. For more conditions options take a look at IdentityQueryBuilder
and use the where(Condition...)
instead.
param
- The query parameter.value
- The value to match for equality.IdentityQuery<T> where(Condition... condition)
Add to this query the conditions that will be used to filter results.
Any condition previously added to this query will be preserved and the new conditions added. If you want to clear the conditions you must create a new query instance.
condition
- One or more conditions created from IdentityQueryBuilder
.IdentityQuery<T> sortBy(Sort... sorts)
Add to this query the sorting conditions to be applied to the results.
sorts
- The ordering conditions.@Deprecated Map<QueryParameter,Object[]> getParameters()
getConditions()
instead. Will be removed.Returns a map with all the parameter set for this query.
Set<Condition> getConditions()
Returns a set containing all conditions used by this query to filter its results.
Set<Sort> getSorting()
Returns a set containing all sorting conditions used to filter the results.
@Deprecated Object[] getParameter(QueryParameter queryParameter)
Returns the value used to restrict the given query parameter.
queryParameter
- @Deprecated Map<QueryParameter,Object[]> getParameters(Class<?> type)
int getOffset()
IdentityQuery<T> setOffset(int offset)
Set the position of the first result to retrieve.
offset
- int getLimit()
Returns the number of instances to retrieve.
IdentityQuery<T> setLimit(int limit)
Set the maximum number of results to retrieve.
limit
- the number of instances to retrieve.List<T> getResultList()
Execute the query against the underlying identity stores and returns a list containing all instances of the type (defined when creating this query instance) that match the conditions previously specified.
int getResultCount()
Copyright © 2018 JBoss by Red Hat. All rights reserved.