public class CriteriaQueryImpl<T> extends AbstractNode implements CriteriaQuery<T>, CompilableCriteria, Serializable
CriteriaQuery
contract. Mostly a set of delegation to its
internal QueryStructure
.Constructor and Description |
---|
CriteriaQueryImpl(CriteriaBuilderImpl criteriaBuilder,
Class<T> returnType) |
Modifier and Type | Method and Description |
---|---|
void |
applySelection(Selection<? extends T> selection) |
CriteriaQuery<T> |
distinct(boolean applyDistinction)
Specify whether duplicate query results will be eliminated.
|
<X> Root<X> |
from(Class<X> entityClass)
Create and add a query root corresponding to the given entity,
forming a cartesian product with any existing roots.
|
<X> Root<X> |
from(EntityType<X> entityType)
Create and add a query root corresponding to the given entity,
forming a cartesian product with any existing roots.
|
List<Expression<?>> |
getGroupList()
Return a list of the grouping expressions.
|
Predicate |
getGroupRestriction()
Return the predicate that corresponds to the restriction(s)
over the grouping items, or null if no restrictions have
been specified.
|
List<Order> |
getOrderList()
Return the ordering expressions in order of precedence.
|
Set<ParameterExpression<?>> |
getParameters()
Return the parameters of the query.
|
Predicate |
getRestriction()
Return the predicate that corresponds to the where clause
restriction(s), or null if no restrictions have been
specified.
|
Class<T> |
getResultType()
Return the result type of the query or subquery.
|
Set<Root<?>> |
getRoots()
Return the query roots.
|
Selection<T> |
getSelection()
Return the selection of the query, or null if no selection
has been set.
|
CriteriaQuery<T> |
groupBy(Expression<?>... groupings)
Specify the expressions that are used to form groups over
the query results.
|
CriteriaQuery<T> |
groupBy(List<Expression<?>> groupings)
Specify the expressions that are used to form groups over
the query results.
|
CriteriaQuery<T> |
having(Expression<Boolean> expression)
Specify a restriction over the groups of the query.
|
CriteriaQuery<T> |
having(Predicate... predicates)
Specify restrictions over the groups of the query
according the conjunction of the specified restriction
predicates.
|
CriteriaInterpretation |
interpret(RenderingContext renderingContext) |
boolean |
isDistinct()
Return whether duplicate query results must be eliminated or
retained.
|
CriteriaQuery<T> |
multiselect(List<Selection<?>> selections)
Specify the selection items that are to be returned in the
query result.
|
CriteriaQuery<T> |
multiselect(Selection<?>... selections)
Specify the selection items that are to be returned in the
query result.
|
CriteriaQuery<T> |
orderBy(List<Order> orders)
Specify the ordering expressions that are used to
order the query results.
|
CriteriaQuery<T> |
orderBy(Order... orders)
Specify the ordering expressions that are used to
order the query results.
|
CriteriaQuery<T> |
select(Selection<? extends T> selection)
Specify the item that is to be returned in the query result.
|
<U> Subquery<U> |
subquery(Class<U> subqueryType)
Create a subquery of the query.
|
void |
validate() |
CriteriaQuery<T> |
where(Expression<Boolean> expression)
Modify the query to restrict the query result according
to the specified boolean expression.
|
CriteriaQuery<T> |
where(Predicate... predicates)
Modify the query to restrict the query result according
to the conjunction of the specified restriction predicates.
|
criteriaBuilder
public CriteriaQueryImpl(CriteriaBuilderImpl criteriaBuilder, Class<T> returnType)
public Class<T> getResultType()
AbstractQuery
createQuery
or subquery
method, that
type will be returned. If the query was created using the
createTupleQuery
method, the result type is
Tuple
. Otherwise, the result type is
Object
.getResultType
in interface AbstractQuery<T>
public CriteriaQuery<T> distinct(boolean applyDistinction)
CriteriaQuery
AbstractQuery
method.distinct
in interface AbstractQuery<T>
distinct
in interface CriteriaQuery<T>
applyDistinction
- boolean value specifying whether duplicate
results must be eliminated from the query result or
whether they must be retainedpublic boolean isDistinct()
AbstractQuery
isDistinct
in interface AbstractQuery<T>
public Selection<T> getSelection()
AbstractQuery
getSelection
in interface AbstractQuery<T>
public CriteriaQuery<T> select(Selection<? extends T> selection)
CriteriaQuery
Note: Applications using the string-based API may need to specify the type of the select item when it results from a get or join operation and the query result type is specified.
For example: CriteriaQuery<String> q = cb.createQuery(String.class); Root<Order> order = q.from(Order.class); q.select(order.get("shippingAddress").<String>get("state")); CriteriaQuery<Product> q2 = cb.createQuery(Product.class); q2.select(q2.from(Order.class) .join("items") .<Item,Product>join("product"));
select
in interface CriteriaQuery<T>
selection
- selection specifying the item that
is to be returned in the query resultpublic CriteriaQuery<T> multiselect(Selection<?>... selections)
CriteriaQuery
An argument to the multiselect method must not be a tuple- or array-valued compound selection item.
The semantics of this method are as follows:
CriteriaQuery<Tuple>
(i.e., a criteria
query object created by either the
createTupleQuery
method or by passing a
Tuple
class argument to the
createQuery
method), a Tuple
object
corresponding to the arguments of the multiselect
method, in the specified order, will be instantiated and
returned for each row that results from the query execution.
CriteriaQuery<X>
for
some user-defined class X (i.e., a criteria query object
created by passing a X class argument to the createQuery
method), the arguments to the multiselect
method will be
passed to the X constructor and an instance of type X will be
returned for each row.
CriteriaQuery<X[]>
for
some class X, an instance of type X[] will be returned for
each row. The elements of the array will correspond to the
arguments of the multiselect
method, in the
specified order.
CriteriaQuery<Object>
or if the criteria query was created without specifying a
type, and only a single argument is passed to the multiselect
method, an instance of type Object
will be returned for
each row.
CriteriaQuery<Object>
or if the criteria query was created without specifying a
type, and more than one argument is passed to the multiselect
method, an instance of type Object[]
will be instantiated
and returned for each row. The elements of the array will
correspond to the arguments to the multiselect
method,
in the specified order.
multiselect
in interface CriteriaQuery<T>
selections
- selection items corresponding to the
results to be returned by the querypublic CriteriaQuery<T> multiselect(List<Selection<?>> selections)
CriteriaQuery
The type of the result of the query execution depends on
the specification of the type of the criteria query object
created as well as the argument to the multiselect
method.
An element of the list passed to the multiselect
method
must not be a tuple- or array-valued compound selection item.
The semantics of this method are as follows:
CriteriaQuery<Tuple>
(i.e., a criteria query object created by either the
createTupleQuery
method or by passing a Tuple
class argument
to the createQuery
method), a Tuple
object corresponding to
the elements of the list passed to the multiselect
method,
in the specified order, will be instantiated and returned for each
row that results from the query execution.
CriteriaQuery<X>
for
some user-defined class X (i.e., a criteria query object
created by passing a X class argument to the createQuery
method), the elements of the list passed to the multiselect
method will be passed to the X constructor and an instance
of type X will be returned for each row.
CriteriaQuery<X[]>
for
some class X, an instance of type X[] will be returned for
each row. The elements of the array will correspond to the
elements of the list passed to the multiselect
method,
in the specified order.
CriteriaQuery<Object>
or if the criteria query was created without specifying a
type, and the list passed to the multiselect
method contains
only a single element, an instance of type Object
will be
returned for each row.
CriteriaQuery<Object>
or if the criteria query was created without specifying a
type, and the list passed to the multiselect
method contains
more than one element, an instance of type Object[]
will be
instantiated and returned for each row. The elements of the
array will correspond to the elements of the list passed to
the multiselect
method, in the specified order.
multiselect
in interface CriteriaQuery<T>
selections
- list of selection items corresponding
to the results to be returned by the querypublic Set<Root<?>> getRoots()
AbstractQuery
CriteriaQuery
or Subquery
itself,
including any subquery roots defined as a result of
correlation. Returns empty set if no roots have been defined.
Modifications to the set do not affect the query.getRoots
in interface AbstractQuery<T>
public <X> Root<X> from(EntityType<X> entityType)
AbstractQuery
from
in interface AbstractQuery<T>
entityType
- metamodel entity representing the entity
of type Xpublic <X> Root<X> from(Class<X> entityClass)
AbstractQuery
from
in interface AbstractQuery<T>
entityClass
- the entity classpublic Predicate getRestriction()
CommonAbstractCriteria
getRestriction
in interface CommonAbstractCriteria
public CriteriaQuery<T> where(Expression<Boolean> expression)
CriteriaQuery
AbstractQuery
method.where
in interface AbstractQuery<T>
where
in interface CriteriaQuery<T>
expression
- a simple or compound boolean expressionpublic CriteriaQuery<T> where(Predicate... predicates)
CriteriaQuery
AbstractQuery
method.where
in interface AbstractQuery<T>
where
in interface CriteriaQuery<T>
predicates
- zero or more restriction predicatespublic List<Expression<?>> getGroupList()
AbstractQuery
getGroupList
in interface AbstractQuery<T>
public CriteriaQuery<T> groupBy(Expression<?>... groupings)
CriteriaQuery
AbstractQuery
method.groupBy
in interface AbstractQuery<T>
groupBy
in interface CriteriaQuery<T>
groupings
- zero or more grouping expressionspublic CriteriaQuery<T> groupBy(List<Expression<?>> groupings)
CriteriaQuery
AbstractQuery
method.groupBy
in interface AbstractQuery<T>
groupBy
in interface CriteriaQuery<T>
groupings
- list of zero or more grouping expressionspublic Predicate getGroupRestriction()
AbstractQuery
getGroupRestriction
in interface AbstractQuery<T>
public CriteriaQuery<T> having(Expression<Boolean> expression)
CriteriaQuery
AbstractQuery
method.having
in interface AbstractQuery<T>
having
in interface CriteriaQuery<T>
expression
- a simple or compound boolean expressionpublic CriteriaQuery<T> having(Predicate... predicates)
CriteriaQuery
AbstractQuery
method.having
in interface AbstractQuery<T>
having
in interface CriteriaQuery<T>
predicates
- zero or more restriction predicatespublic List<Order> getOrderList()
CriteriaQuery
getOrderList
in interface CriteriaQuery<T>
public CriteriaQuery<T> orderBy(Order... orders)
CriteriaQuery
orderBy
in interface CriteriaQuery<T>
orders
- zero or more ordering expressionspublic CriteriaQuery<T> orderBy(List<Order> orders)
CriteriaQuery
orderBy
in interface CriteriaQuery<T>
orders
- list of zero or more ordering expressionspublic Set<ParameterExpression<?>> getParameters()
CriteriaQuery
getParameters
in interface CriteriaQuery<T>
public <U> Subquery<U> subquery(Class<U> subqueryType)
CommonAbstractCriteria
subquery
in interface CommonAbstractCriteria
subqueryType
- the subquery result typepublic void validate()
validate
in interface CompilableCriteria
public CriteriaInterpretation interpret(RenderingContext renderingContext)
interpret
in interface CompilableCriteria
Copyright © 2021 JBoss by Red Hat. All rights reserved.