Class CriteriaQueryImpl<T>
- java.lang.Object
-
- org.eclipse.persistence.internal.jpa.querydef.CommonAbstractCriteriaImpl<T>
-
- org.eclipse.persistence.internal.jpa.querydef.AbstractQueryImpl<T>
-
- org.eclipse.persistence.internal.jpa.querydef.CriteriaQueryImpl<T>
-
- All Implemented Interfaces:
java.io.Serializable,javax.persistence.criteria.AbstractQuery<T>,javax.persistence.criteria.CommonAbstractCriteria,javax.persistence.criteria.CriteriaQuery<T>
public class CriteriaQueryImpl<T> extends AbstractQueryImpl<T> implements javax.persistence.criteria.CriteriaQuery<T>
Purpose: Contains the implementation of the CriteriaQuery interface of the JPA criteria API.
Description: This is the container class for the components that define a query.
- Since:
- EclipseLink 1.2
- Author:
- gyorke
- See Also:
CriteriaQuery, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.persistence.internal.jpa.querydef.AbstractQueryImpl
AbstractQueryImpl.ResultType
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<FromImpl>joinsprotected java.util.List<javax.persistence.criteria.Order>orderByprotected SelectionImpl<?>selection-
Fields inherited from class org.eclipse.persistence.internal.jpa.querydef.AbstractQueryImpl
baseExpression, distinct, groupBy, havingClause, queryResult, roots
-
Fields inherited from class org.eclipse.persistence.internal.jpa.querydef.CommonAbstractCriteriaImpl
metamodel, parameters, queryBuilder, queryType, where
-
-
Constructor Summary
Constructors Constructor Description CriteriaQueryImpl(javax.persistence.metamodel.Metamodel metamodel, AbstractQueryImpl.ResultType queryResult, java.lang.Class result, CriteriaBuilderImpl queryBuilder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddJoin(FromImpl from)protected org.eclipse.persistence.queries.ObjectLevelReadQuerycreateCompoundQuery()Translates from the criteria query to a EclipseLink Database Query.protected org.eclipse.persistence.queries.ObjectLevelReadQuerycreateSimpleQuery()javax.persistence.criteria.CriteriaQuery<T>distinct(boolean distinct)Specify whether duplicate query results will be eliminated.protected org.eclipse.persistence.queries.DatabaseQuerygetDatabaseQuery()java.util.List<javax.persistence.criteria.Order>getOrderList()Return the ordering expressions in order of precedence.javax.persistence.criteria.Selection<T>getSelection()Return the selection item of the query.javax.persistence.criteria.CriteriaQuery<T>groupBy(java.util.List<javax.persistence.criteria.Expression<?>> grouping)Specify the expressions that are used to form groups over the query results.javax.persistence.criteria.CriteriaQuery<T>groupBy(javax.persistence.criteria.Expression<?>... grouping)Specify the expressions that are used to form groups over the query results.javax.persistence.criteria.CriteriaQuery<T>having(javax.persistence.criteria.Expression<java.lang.Boolean> restriction)Specify a restriction over the groups of the query.javax.persistence.criteria.CriteriaQuery<T>having(javax.persistence.criteria.Predicate... restrictions)Specify restrictions over the groups of the query according the conjunction of the specified restriction predicates.javax.persistence.criteria.CriteriaQuery<T>multiselect(java.util.List<javax.persistence.criteria.Selection<?>> selectionList)Specify the items that are to be returned in the query result.javax.persistence.criteria.CriteriaQuery<T>multiselect(javax.persistence.criteria.Selection<?>... selections)Specify the items that are to be returned in the query result.javax.persistence.criteria.CriteriaQuery<T>orderBy(java.util.List<javax.persistence.criteria.Order> o)Specify the ordering expressions that are used to order the query results.javax.persistence.criteria.CriteriaQuery<T>orderBy(javax.persistence.criteria.Order... o)Specify the ordering expressions that are used to order the query results.voidpopulateAndSetConstructorSelection(ConstructorSelectionImpl constructorSelection, java.lang.Class<?> class1, javax.persistence.criteria.Selection<?>... selections)This method will set this queryImpl's selection to a ConstructorSelectionImpl, creating a new instance or populating the one passed in as necessary.javax.persistence.criteria.CriteriaQuery<T>select(javax.persistence.criteria.Selection<? extends T> selection)Specify the item that is to be returned in the query result.org.eclipse.persistence.queries.DatabaseQuerytranslate()Translates from the criteria query to a EclipseLink Database Query.javax.persistence.criteria.CriteriaQuery<T>where(javax.persistence.criteria.Expression<java.lang.Boolean> restriction)Modify the query to restrict the query result according to the specified boolean expression.javax.persistence.criteria.CriteriaQuery<T>where(javax.persistence.criteria.Predicate... restrictions)Modify the query to restrict the query result according to the conjunction of the specified restriction predicates.-
Methods inherited from class org.eclipse.persistence.internal.jpa.querydef.AbstractQueryImpl
findJoins, from, from, getBaseExpression, getBaseExpression, getGroupList, getGroupRestriction, getRoots, integrateRoot, isDistinct
-
Methods inherited from class org.eclipse.persistence.internal.jpa.querydef.CommonAbstractCriteriaImpl
addParameter, findRootAndParameters, findRootAndParameters, getParameters, getRestriction, getResultType, internalFrom, internalFrom, subquery
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.persistence.criteria.AbstractQuery
from, from, getGroupList, getGroupRestriction, getResultType, getRoots, isDistinct
-
-
-
-
Field Detail
-
selection
protected SelectionImpl<?> selection
-
orderBy
protected java.util.List<javax.persistence.criteria.Order> orderBy
-
joins
protected java.util.Set<FromImpl> joins
-
-
Constructor Detail
-
CriteriaQueryImpl
public CriteriaQueryImpl(javax.persistence.metamodel.Metamodel metamodel, AbstractQueryImpl.ResultType queryResult, java.lang.Class result, CriteriaBuilderImpl queryBuilder)
-
-
Method Detail
-
select
public javax.persistence.criteria.CriteriaQuery<T> select(javax.persistence.criteria.Selection<? extends T> selection)
Specify the item that is to be returned in the query result. Replaces the previously specified selection, if any.- Specified by:
selectin interfacejavax.persistence.criteria.CriteriaQuery<T>- Parameters:
selection- selection specifying the item that is to be returned in the query result- Returns:
- the modified query
-
multiselect
public javax.persistence.criteria.CriteriaQuery<T> multiselect(javax.persistence.criteria.Selection<?>... selections)
Specify the items that are to be returned in the query result. Replaces the previously specified selection(s), if any. The type of the result of the query execution depends on the specification of the criteria query object as well as the arguments to the multiselect method as follows: If the type of the criteria query is CriteriaQuery<Tuple>, a Tuple object corresponding to the arguments of the multiselect method will be instantiated and returned for each row that results from the query execution. If the type of the criteria query is CriteriaQuery<X> for some user-defined class X, then 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. The IllegalStateException will be thrown if a constructor for the given argument types does not exist. If the type of the criteria query is 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. The IllegalStateException will be thrown if the arguments to the multiselect method are not of type X. If the type of the criteria query is CriteriaQuery<Object>, and only a single argument is passed to the multiselect method, an instance of type Object will be returned for each row. If the type of the criteria query is CriteriaQuery<Object>, 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.- Specified by:
multiselectin interfacejavax.persistence.criteria.CriteriaQuery<T>- Parameters:
selections- expressions specifying the items that are to be returned in the query result- Returns:
- the modified query
-
multiselect
public javax.persistence.criteria.CriteriaQuery<T> multiselect(java.util.List<javax.persistence.criteria.Selection<?>> selectionList)
Specify the items that are to be returned in the query result. Replaces the previously specified selection(s), if any. The type of the result of the query execution depends on the specification of the criteria query object as well as the arguments to the multiselect method as follows: If the type of the criteria query is CriteriaQuery<Tuple>, a Tuple object corresponding to the items in the selection list passed to the multiselect method will be instantiated and returned for each row that results from the query execution. If the type of the criteria query is CriteriaQuery<X> for some user-defined class X, then the items in the selection 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. The IllegalStateException will be thrown if a constructor for the given argument types does not exist. If the type of the criteria query is 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 items in the selection list passed to the multiselect method. The IllegalStateException will be thrown if the elements in the selection list passed to the multiselect method are not of type X. If the type of the criteria query is CriteriaQuery<Object>, and the selection list passed to the multiselect method contains only a single item, an instance of type Object will be returned for each row. If the type of the criteria query is CriteriaQuery<Object>, and the selection list passed to the multiselect method contains more than one item, an instance of type Object[] will be instantiated and returned for each row. The elements of the array will correspond to the items in the selection list passed to the multiselect method.- Specified by:
multiselectin interfacejavax.persistence.criteria.CriteriaQuery<T>- Parameters:
selectionList- list of expressions specifying the items that to be are returned in the query result- Returns:
- the modified query
-
where
public javax.persistence.criteria.CriteriaQuery<T> where(javax.persistence.criteria.Expression<java.lang.Boolean> restriction)
Modify the query to restrict the query result according to the specified boolean expression. Replaces the previously added restriction(s), if any. This method only overrides the return type of the corresponding AbstractQuery method.- Specified by:
wherein interfacejavax.persistence.criteria.AbstractQuery<T>- Specified by:
wherein interfacejavax.persistence.criteria.CriteriaQuery<T>- Overrides:
wherein classAbstractQueryImpl<T>- Parameters:
restriction- a simple or compound boolean expression- Returns:
- the modified query
-
where
public javax.persistence.criteria.CriteriaQuery<T> where(javax.persistence.criteria.Predicate... restrictions)
Modify the query to restrict the query result according to the conjunction of the specified restriction predicates. Replaces the previously added restriction(s), if any. If no restrictions are specified, any previously added restrictions are simply removed. This method only overrides the return type of the corresponding AbstractQuery method.- Specified by:
wherein interfacejavax.persistence.criteria.AbstractQuery<T>- Specified by:
wherein interfacejavax.persistence.criteria.CriteriaQuery<T>- Overrides:
wherein classAbstractQueryImpl<T>- Parameters:
restrictions- zero or more restriction predicates- Returns:
- the modified query
-
groupBy
public javax.persistence.criteria.CriteriaQuery<T> groupBy(javax.persistence.criteria.Expression<?>... grouping)
Specify the expressions that are used to form groups over the query results. Replaces the previous specified grouping expressions, if any. If no grouping expressions are specified, any previously added grouping expressions are simply removed. This method only overrides the return type of the corresponding AbstractQuery method.- Specified by:
groupByin interfacejavax.persistence.criteria.AbstractQuery<T>- Specified by:
groupByin interfacejavax.persistence.criteria.CriteriaQuery<T>- Overrides:
groupByin classAbstractQueryImpl<T>- Parameters:
grouping- zero or more grouping expressions- Returns:
- the modified query
-
groupBy
public javax.persistence.criteria.CriteriaQuery<T> groupBy(java.util.List<javax.persistence.criteria.Expression<?>> grouping)
Specify the expressions that are used to form groups over the query results. Replaces the previous specified grouping expressions, if any. If no grouping expressions are specified, any previously added grouping expressions are simply removed. This method only overrides the return type of the corresponding AbstractQuery method.- Specified by:
groupByin interfacejavax.persistence.criteria.AbstractQuery<T>- Specified by:
groupByin interfacejavax.persistence.criteria.CriteriaQuery<T>- Overrides:
groupByin classAbstractQueryImpl<T>- Parameters:
grouping- list of zero or more grouping expressions- Returns:
- the modified query
-
having
public javax.persistence.criteria.CriteriaQuery<T> having(javax.persistence.criteria.Expression<java.lang.Boolean> restriction)
Specify a restriction over the groups of the query. Replaces the previous having restriction(s), if any. This method only overrides the return type of the corresponding AbstractQuery method.- Specified by:
havingin interfacejavax.persistence.criteria.AbstractQuery<T>- Specified by:
havingin interfacejavax.persistence.criteria.CriteriaQuery<T>- Overrides:
havingin classAbstractQueryImpl<T>- Parameters:
restriction- a simple or compound boolean expression- Returns:
- the modified query
-
having
public javax.persistence.criteria.CriteriaQuery<T> having(javax.persistence.criteria.Predicate... restrictions)
Specify restrictions over the groups of the query according the conjunction of the specified restriction predicates. Replaces the previously added restriction(s), if any. If no restrictions are specified, any previously added restrictions are simply removed. This method only overrides the return type of the corresponding AbstractQuery method.- Specified by:
havingin interfacejavax.persistence.criteria.AbstractQuery<T>- Specified by:
havingin interfacejavax.persistence.criteria.CriteriaQuery<T>- Overrides:
havingin classAbstractQueryImpl<T>- Parameters:
restrictions- zero or more restriction predicates- Returns:
- the modified query
-
orderBy
public javax.persistence.criteria.CriteriaQuery<T> orderBy(javax.persistence.criteria.Order... o)
Specify the ordering expressions that are used to order the query results. Replaces the previous ordering expressions, if any. If no ordering expressions are specified, the previous ordering, if any, is simply removed, and results will be returned in no particular order. The left-to-right sequence of the ordering expressions determines the precedence, whereby the leftmost has highest precedence.- Specified by:
orderByin interfacejavax.persistence.criteria.CriteriaQuery<T>- Parameters:
o- zero or more ordering expressions- Returns:
- the modified query.
-
orderBy
public javax.persistence.criteria.CriteriaQuery<T> orderBy(java.util.List<javax.persistence.criteria.Order> o)
Specify the ordering expressions that are used to order the query results. Replaces the previous ordering expressions, if any. If no ordering expressions are specified, the previous ordering, if any, is simply removed, and results will be returned in no particular order. The order of the ordering expressions in the list determines the precedence, whereby the first element in the list has highest precedence.- Specified by:
orderByin interfacejavax.persistence.criteria.CriteriaQuery<T>- Parameters:
o- list of zero or more ordering expressions- Returns:
- the modified query.
-
populateAndSetConstructorSelection
public void populateAndSetConstructorSelection(ConstructorSelectionImpl constructorSelection, java.lang.Class<?> class1, javax.persistence.criteria.Selection<?>... selections) throws java.lang.IllegalArgumentException
This method will set this queryImpl's selection to a ConstructorSelectionImpl, creating a new instance or populating the one passed in as necessary. Throws IllegalArgumentException if a constructor taking arguments represented by the selections array doesn't exist for the given class. Also sets the query result to ResultType.CONSTRUCTOR- Parameters:
class1-selections-- Throws:
java.lang.IllegalArgumentException
-
distinct
public javax.persistence.criteria.CriteriaQuery<T> distinct(boolean distinct)
Specify whether duplicate query results will be eliminated. A true value will cause duplicates to be eliminated. A false value will cause duplicates to be retained. If distinct has not been specified, duplicate results must be retained. This method only overrides the return type of the corresponding AbstractQuery method.- Specified by:
distinctin interfacejavax.persistence.criteria.AbstractQuery<T>- Specified by:
distinctin interfacejavax.persistence.criteria.CriteriaQuery<T>- Overrides:
distinctin classAbstractQueryImpl<T>- Parameters:
distinct- boolean value specifying whether duplicate results must be eliminated from the query result or whether they must be retained- Returns:
- the modified query.
-
addJoin
public void addJoin(FromImpl from)
- Specified by:
addJoinin classAbstractQueryImpl<T>
-
getDatabaseQuery
protected org.eclipse.persistence.queries.DatabaseQuery getDatabaseQuery()
- Specified by:
getDatabaseQueryin classCommonAbstractCriteriaImpl<T>
-
getOrderList
public java.util.List<javax.persistence.criteria.Order> getOrderList()
Return the ordering expressions in order of precedence.- Specified by:
getOrderListin interfacejavax.persistence.criteria.CriteriaQuery<T>- Returns:
- the list of ordering expressions
-
getSelection
public javax.persistence.criteria.Selection<T> getSelection()
Return the selection item of the query. This will correspond to the query type.- Specified by:
getSelectionin interfacejavax.persistence.criteria.AbstractQuery<T>- Returns:
- the selection item of the query
-
createCompoundQuery
protected org.eclipse.persistence.queries.ObjectLevelReadQuery createCompoundQuery()
Translates from the criteria query to a EclipseLink Database Query.
-
createSimpleQuery
protected org.eclipse.persistence.queries.ObjectLevelReadQuery createSimpleQuery()
-
translate
public org.eclipse.persistence.queries.DatabaseQuery translate()
Translates from the criteria query to a EclipseLink Database Query.- Overrides:
translatein classCommonAbstractCriteriaImpl<T>
-
-