org.apache.openjpa.persistence.query
Interface QueryDefinition

All Superinterfaces:
PredicateOperand, Subquery
All Known Subinterfaces:
DomainObject
All Known Implementing Classes:
AbstractDomainObject, EntryExpression, FetchPath, JoinPath, KeyExpression, NavigationPath, OperatorPath, QueryDefinitionImpl, RootPath, ValueExpression

public interface QueryDefinition
extends Subquery

Interface for construction of query definitions


Method Summary
 DomainObject addRoot(Class cls)
          Add a query root corresponding to the given entity, forming a cartesian product with any existing roots.
 DomainObject addSubqueryRoot(PathExpression path)
          Add a root derived from a domain object of the containing query definition to a query definition used as a subquery.
 Subquery all()
          Use the query definition object in a subquery in an all expression.
 Subquery any()
          Use the query definition object in a subquery in an any expression.
 Expression coalesce(Calendar... exp)
          coalesce This is equivalent to a case expression that returns null if all its arguments evaluate to null, and the value of its first non-null argument otherwise.
 Expression coalesce(Date... exp)
          coalesce This is equivalent to a case expression that returns null if all its arguments evaluate to null, and the value of its first non-null argument otherwise.
 Expression coalesce(Expression... exp)
          coalesce This is equivalent to a case expression that returns null if all its arguments evaluate to null, and the value of its first non-null argument otherwise.
 Expression coalesce(String... exp)
          coalesce This is equivalent to a case expression that returns null if all its arguments evaluate to null, and the value of its first non-null argument otherwise.
 Expression currentDate()
          Create an Expression corresponding to the current date on the database server at the time of query execution.
 Expression currentTime()
          Create an Expression corresponding to the current time on the database server at the time of query execution.
 Expression currentTimestamp()
          Create an Expression corresponding to the current timestamp on the database server at the time of query execution.
 Predicate exists()
          Use the query definition instance as a subquery in an exists predicate.
 CaseExpression generalCase()
          Create an empty general case expression.
 QueryDefinition groupBy(List<PathExpression> pathExprList)
          Specify the items that are used to form groups over the query results.
 QueryDefinition groupBy(PathExpression... pathExprs)
          Specify the items that are used to form groups over the query results.
 QueryDefinition having(Predicate predicate)
          Specify the restrictions over the groups of a query.
 Expression literal(boolean b)
          Create an Expression corresponding to a boolean value.
 Expression literal(Calendar c)
          Create an Expression corresponding to a Calendar value.
 Expression literal(char c)
          Create an Expression corresponding to a character value.
 Expression literal(Class cls)
          Create an Expression corresponding to an entity class.
 Expression literal(Date d)
          Create an Expression corresponding to a Date value.
 Expression literal(Enum<?> e)
          Create an Expression corresponding to an enum.
 Expression literal(Number n)
          Create an Expression corresponding to a numeric value.
 Expression literal(String s)
          Create an Expression corresponding to a String value.
 SelectItem newInstance(Class cls, SelectItem... args)
          Specify that a constructor for the given class is to be applied to the corresponding query results after the query is executed.
 Expression nullif(Calendar arg1, Calendar arg2)
          nullif This is equivalent to a case expression that tests whether its arguments are equal, returning null if they are and the value of the first expression if they are not.
 Expression nullif(Class arg1, Class arg2)
          nullif This is equivalent to a case expression that tests whether its arguments are equal, returning null if they are and the value of the first expression if they are not.
 Expression nullif(Date arg1, Date arg2)
          nullif This is equivalent to a case expression that tests whether its arguments are equal, returning null if they are and the value of the first expression if they are not.
 Expression nullif(Enum<?> arg1, Enum<?> arg2)
          nullif This is equivalent to a case expression that tests whether its arguments are equal, returning null if they are and the value of the first expression if they are not.
 Expression nullif(Expression exp1, Expression exp2)
          nullif This is equivalent to a case expression that tests whether its arguments are equal, returning null if they are and the value of the first expression if they are not.
 Expression nullif(Number arg1, Number arg2)
          nullif This is equivalent to a case expression that tests whether its arguments are equal, returning null if they are and the value of the first expression if they are not.
 Expression nullif(String arg1, String arg2)
          nullif This is equivalent to a case expression that tests whether its arguments are equal, returning null if they are and the value of the first expression if they are not.
 Expression nullLiteral()
          Create an Expression corresponding to a null value.
 QueryDefinition orderBy(List<OrderByItem> orderByItemList)
          Specify the items of the select list that are used in ordering the query results.
 QueryDefinition orderBy(OrderByItem... orderByItems)
          Specify the items of the select list that are used in ordering the query results.
 Expression param(String name)
          Specify use of a parameter of the given name.
 Predicate predicate(boolean b)
          Create a predicate value from the given boolean.
 QueryDefinition select(List<SelectItem> selectItemList)
          Specify the objects / values to be returned.
 QueryDefinition select(SelectItem... selectItems)
          Specify the objects / values to be returned.
 QueryDefinition selectDistinct(List<SelectItem> selectItemList)
          Specify the objects / values to be returned.
 QueryDefinition selectDistinct(SelectItem... selectItems)
          Specify the objects / values to be returned.
 CaseExpression simpleCase(Calendar caseOperand)
          Create a simple case expression with the given case operand.
 CaseExpression simpleCase(Class caseOperand)
          Create a simple case expression with the given case operand.
 CaseExpression simpleCase(Date caseOperand)
          Create a simple case expression with the given case operand.
 CaseExpression simpleCase(Enum<?> caseOperand)
          Create a simple case expression with the given case operand.
 CaseExpression simpleCase(Expression caseOperand)
          Create a simple case expression with the given case operand.
 CaseExpression simpleCase(Number caseOperand)
          Create a simple case expression with the given case operand.
 CaseExpression simpleCase(String caseOperand)
          Create a simple case expression with the given case operand.
 Subquery some()
          Use the query definition object in a subquery in a some expression.
 QueryDefinition where(Predicate predicate)
          Modifies the query definition to restrict the result of the query according to the specified predicate.
 
Methods inherited from interface org.apache.openjpa.persistence.query.PredicateOperand
between, between, between, between, between, between, between, between, between, between, between, between, between, equal, equal, equal, equal, equal, equal, equal, equal, greaterEqual, greaterEqual, greaterEqual, greaterEqual, greaterEqual, greaterThan, greaterThan, greaterThan, greaterThan, greaterThan, lessEqual, lessEqual, lessEqual, lessEqual, lessEqual, lessThan, lessThan, lessThan, lessThan, lessThan, like, like, like, like, like, like, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual, notEqual
 

Method Detail

addRoot

DomainObject addRoot(Class cls)
Add a query root corresponding to the given entity, forming a cartesian product with any existing roots. The domain object that is returned is bound as a component of the given query. The argument must be an entity class.

Parameters:
cls - - an entity class
Returns:
DomainObject corresponding to the specified entity class.

addSubqueryRoot

DomainObject addSubqueryRoot(PathExpression path)
Add a root derived from a domain object of the containing query definition to a query definition used as a subquery. Provides support for correlated subqueries. Joins against the resulting domain object do not affect the query domain of the containing query. The path expression must correspond to an entity class. The path expression must not be a domain object of the containing query.

Parameters:
path - - path expression corresponding to the domain object used to derive the subquery root.
Returns:
the subquery DomainObject

select

QueryDefinition select(SelectItem... selectItems)
Specify the objects / values to be returned. Replaces the previous select list, if any. If no select items are specified and there is only one query root, the root entity is assumed to be the result.

Parameters:
selectItems - - one or more SelectItem instances
Returns:
the modified query definition instance

select

QueryDefinition select(List<SelectItem> selectItemList)
Specify the objects / values to be returned. Replaces the previous select list, if any. If no select items are specified and there is only one query root, the root entity is assumed to be the result.

Parameters:
selectItemList - - a list containing one or more SelectItem instances
Returns:
the modified query definition instance

selectDistinct

QueryDefinition selectDistinct(SelectItem... selectItems)
Specify the objects / values to be returned. Duplicate results will be eliminated. Replaces the previous select list, if any. If no select items are specified and there is only one query root, the root entity is assumed to be the result.

Parameters:
selectItems - - one or more SelectItem instances
Returns:
the modified query definition instance

selectDistinct

QueryDefinition selectDistinct(List<SelectItem> selectItemList)
Specify the objects / values to be returned. Duplicate results will be eliminated. Replaces the previous select list, if any. If no select items are specified, and there is only one query root, the root entity is assumed to be the result. is assumed to be the result.

Parameters:
selectItemList - - a list containing one or more SelectItem instances
Returns:
the modified query definition instance

where

QueryDefinition where(Predicate predicate)
Modifies the query definition to restrict the result of the query according to the specified predicate. Replaces the previously added restriction(s), if any.

Parameters:
predicate - - a simple or compound conditional predicate
Returns:
the modified QueryDefinition instance

orderBy

QueryDefinition orderBy(OrderByItem... orderByItems)
Specify the items of the select list that are used in ordering the query results. Replaces the previous order-by list, if any.

Parameters:
orderByItems - - one or more OrderByItem instances
Returns:
the modified QueryDefinition instance

orderBy

QueryDefinition orderBy(List<OrderByItem> orderByItemList)
Specify the items of the select list that are used in ordering the query results. Replaces the previous order-by list, if any.

Parameters:
orderByItemList - - a list containing one or more OrderByItem instances
Returns:
the modified QueryDefinition instance

groupBy

QueryDefinition groupBy(PathExpression... pathExprs)
Specify the items that are used to form groups over the query results. Replaces the previous group-by list, if any.

Parameters:
pathExprs -
Returns:
the modified QueryDefinition instance

groupBy

QueryDefinition groupBy(List<PathExpression> pathExprList)
Specify the items that are used to form groups over the query results. Replaces the previous group-by list, if any.

Parameters:
pathExprList -
Returns:
the modified QueryDefinition instance

having

QueryDefinition having(Predicate predicate)
Specify the restrictions over the groups of a query. Replaces the previous having restriction(s), if any.

Parameters:
predicate -
Returns:
the modified QueryDefinition Instance

newInstance

SelectItem newInstance(Class cls,
                       SelectItem... args)
Specify that a constructor for the given class is to be applied to the corresponding query results after the query is executed. The class must have a constructor that accepts the Java argument types corresponding to the given select items.

Parameters:
cls - - a class with the correponding constructor
args - - select items that correspond to result types that are valid as arguments to the constructor

exists

Predicate exists()
Use the query definition instance as a subquery in an exists predicate.

Returns:
the resulting predicate

all

Subquery all()
Use the query definition object in a subquery in an all expression.

Returns:
the resulting Subquery

any

Subquery any()
Use the query definition object in a subquery in an any expression.

Returns:
the resulting Subquery

some

Subquery some()
Use the query definition object in a subquery in a some expression.

Returns:
the resulting Subquery

generalCase

CaseExpression generalCase()
Create an empty general case expression. A general case expression is of the form:

generalCase() .when(conditional-predicate).then(scalar-expression) .when(conditional-predicate).then(scalar-expression) ... .elseCase(scalar-expression)

Returns:
empty general case expression

simpleCase

CaseExpression simpleCase(Expression caseOperand)
Create a simple case expression with the given case operand. A simple case expression is of the form:

simpleCase(case-operand) .when(scalar-expression).then(scalar-expression) .when(scalar-expression).then(scalar-expression) ... .elseCase(scalar-expression)

Parameters:
caseOperand - - expression used for testing against the when scalar expressions
Returns:
case expression with the given case operand

simpleCase

CaseExpression simpleCase(Number caseOperand)
Create a simple case expression with the given case operand. A simple case expression is of the form:

simpleCase(case-operand) .when(scalar-expression).then(scalar-expression) .when(scalar-expression).then(scalar-expression) ... .elseCase(scalar-expression)

Parameters:
caseOperand - - numeric value used for testing against the when scalar expressions
Returns:
case expression with the given case operand

simpleCase

CaseExpression simpleCase(String caseOperand)
Create a simple case expression with the given case operand. A simple case expression is of the form:

simpleCase(case-operand) .when(scalar-expression).then(scalar-expression) .when(scalar-expression).then(scalar-expression) ... .elseCase(scalar-expression)

Parameters:
caseOperand - - value used for testing against the when scalar expressions
Returns:
case expression with the given case operand

simpleCase

CaseExpression simpleCase(Date caseOperand)
Create a simple case expression with the given case operand. A simple case expression is of the form:

simpleCase(case-operand) .when(scalar-expression).then(scalar-expression) .when(scalar-expression).then(scalar-expression) ... .elseCase(scalar-expression)

Parameters:
caseOperand - - value used for testing against the when scalar expressions
Returns:
case expression with the given case operand

simpleCase

CaseExpression simpleCase(Calendar caseOperand)
Create a simple case expression with the given case operand. A simple case expression is of the form:

simpleCase(case-operand) .when(scalar-expression).then(scalar-expression) .when(scalar-expression).then(scalar-expression) ... .elseCase(scalar-expression)

Parameters:
caseOperand - - value used for testing against the when scalar expressions
Returns:
case expression with the given case operand

simpleCase

CaseExpression simpleCase(Class caseOperand)
Create a simple case expression with the given case operand. A simple case expression is of the form:

simpleCase(case-operand) .when(scalar-expression).then(scalar-expression) .when(scalar-expression).then(scalar-expression) ... .elseCase(scalar-expression)

Parameters:
caseOperand - - value used for testing against the when scalar expressions
Returns:
case expression with the given case operand

simpleCase

CaseExpression simpleCase(Enum<?> caseOperand)
Create a simple case expression with the given case operand. A simple case expression is of the form:

simpleCase(case-operand) .when(scalar-expression).then(scalar-expression) .when(scalar-expression).then(scalar-expression) ... .elseCase(scalar-expression)

Parameters:
caseOperand - - value used for testing against the when scalar expressions
Returns:
case expression with the given case operand

coalesce

Expression coalesce(Expression... exp)
coalesce This is equivalent to a case expression that returns null if all its arguments evaluate to null, and the value of its first non-null argument otherwise.

Parameters:
exp - - expressions to be used for testing against null
Returns:
Expression corresponding to the given coalesce expression

coalesce

Expression coalesce(String... exp)
coalesce This is equivalent to a case expression that returns null if all its arguments evaluate to null, and the value of its first non-null argument otherwise.

Parameters:
exp - - expressions to be used for testing against null
Returns:
Expression corresponding to the given coalesce expression

coalesce

Expression coalesce(Date... exp)
coalesce This is equivalent to a case expression that returns null if all its arguments evaluate to null, and the value of its first non-null argument otherwise.

Parameters:
exp - - expressions to be used for testing against null
Returns:
Expression corresponding to the given coalesce expression

coalesce

Expression coalesce(Calendar... exp)
coalesce This is equivalent to a case expression that returns null if all its arguments evaluate to null, and the value of its first non-null argument otherwise.

Parameters:
exp - - expressions to be used for testing against null
Returns:
Expression corresponding to the given coalesce expression

nullif

Expression nullif(Expression exp1,
                  Expression exp2)
nullif This is equivalent to a case expression that tests whether its arguments are equal, returning null if they are and the value of the first expression if they are not.

Parameters:
exp1 -
exp2 -
Returns:
Expression corresponding to the given nullif expression

nullif

Expression nullif(Number arg1,
                  Number arg2)
nullif This is equivalent to a case expression that tests whether its arguments are equal, returning null if they are and the value of the first expression if they are not.

Parameters:
arg1 -
arg2 -
Returns:
Expression corresponding to the given nullif expression

nullif

Expression nullif(String arg1,
                  String arg2)
nullif This is equivalent to a case expression that tests whether its arguments are equal, returning null if they are and the value of the first expression if they are not.

Parameters:
arg1 -
arg2 - Criteria API Java Persistence 2.0, Public Review Draft Criteria API Interfaces 10/31/08 158 JSR-317 Public Review Draft Sun Microsystems, Inc.
Returns:
Expression corresponding to the given nullif expression

nullif

Expression nullif(Date arg1,
                  Date arg2)
nullif This is equivalent to a case expression that tests whether its arguments are equal, returning null if they are and the value of the first expression if they are not.

Parameters:
arg1 -
arg2 -
Returns:
Expression corresponding to the given nullif expression

nullif

Expression nullif(Calendar arg1,
                  Calendar arg2)
nullif This is equivalent to a case expression that tests whether its arguments are equal, returning null if they are and the value of the first expression if they are not.

Parameters:
arg1 -
arg2 -
Returns:
Expression corresponding to the given nullif expression

nullif

Expression nullif(Class arg1,
                  Class arg2)
nullif This is equivalent to a case expression that tests whether its arguments are equal, returning null if they are and the value of the first expression if they are not.

Parameters:
arg1 -
arg2 -
Returns:
Expression corresponding to the given nullif expression

nullif

Expression nullif(Enum<?> arg1,
                  Enum<?> arg2)
nullif This is equivalent to a case expression that tests whether its arguments are equal, returning null if they are and the value of the first expression if they are not.

Parameters:
arg1 -
arg2 -
Returns:
Expression corresponding to the given nullif expression

predicate

Predicate predicate(boolean b)
Create a predicate value from the given boolean.

Parameters:
b - boolean value
Returns:
a true or false predicate

currentTime

Expression currentTime()
Create an Expression corresponding to the current time on the database server at the time of query execution.

Returns:
the corresponding Expression

currentDate

Expression currentDate()
Create an Expression corresponding to the current date on the database server at the time of query execution.

Returns:
the corresponding Expression

currentTimestamp

Expression currentTimestamp()
Create an Expression corresponding to the current timestamp on the database server at the time of query execution.

Returns:
the corresponding Expression

literal

Expression literal(String s)
Create an Expression corresponding to a String value.

Parameters:
s - - string value
Returns:
the corresponding Expression literal

literal

Expression literal(Number n)
Create an Expression corresponding to a numeric value.

Parameters:
n - - numeric value
Returns:
the corresponding Expression literal

literal

Expression literal(boolean b)
Create an Expression corresponding to a boolean value.

Parameters:
b - - boolean value
Returns:
the corresponding Expression literal

literal

Expression literal(Calendar c)
Create an Expression corresponding to a Calendar value.

Parameters:
c - - Calendar value
Returns:
the corresponding Expression literal

literal

Expression literal(Date d)
Create an Expression corresponding to a Date value.

Parameters:
d - - Date value
Returns:
the corresponding Expression literal

literal

Expression literal(char c)
Create an Expression corresponding to a character value.

Parameters:
character - value
Returns:
the corresponding Expression literal

literal

Expression literal(Class cls)
Create an Expression corresponding to an entity class.

Parameters:
cls - - entity class
Returns:
the corresponding Expression literal

literal

Expression literal(Enum<?> e)
Create an Expression corresponding to an enum.

Parameters:
e - - enum
Returns:
the corresponding Expression literal

nullLiteral

Expression nullLiteral()
Create an Expression corresponding to a null value.

Returns:
the corresponding Expression literal

param

Expression param(String name)
Specify use of a parameter of the given name.

Parameters:
parameter - name
Returns:
an Expression corresponding to a named parameter


Copyright © 2006-2012 Apache Software Foundation. All Rights Reserved.