Java Reference
In-Depth Information
Passing parameters: positional and named
Recall from our earlier discussion that JPQL supports two types of parameters: positional
and named. Later in this chapter we'll show you how to set values for both named and po-
sitional parameters.
The value of the parameter isn't limited to numeric or string types; the value depends on
the type of path expression used in the WHERE clause. The parameter can take more com-
plex types, such as another entity type, but you're limited to using conditional expressions
that involve a single-value path expression.
Conditional expressions and operators
A condition in the WHERE clause that filters results from a query is known as a conditional
expression. You can build a conditional expression using path expressions and operators
supported by the language. JPQL can evaluate a path expression with numeric, string, or
boolean values using relational operators. Here's an example of a conditional expres-
sion:
c.categoryName = 'Dumped Cars'
Table 11.3 lists the types of operators supported by JPQL, in order of precedence.
Table 11.3. Operator types supported by JPQL
Operator type
Operator
Navigational
.
Unary sign
+,-
Arithmetic
*, /, +, -
=, >, >=, <, <=, <>, [NOT] BETWEEN, [NOT] LIKE,
[NOT] IN, IS [NOT] NULL, IS [NOT] EMPTY, [NOT]
MEMBER [OF]
Relational
Logical
NOT, AND, OR
A complex conditional expression may include other expressions that are combined for
evaluation using logical operators such as AND or OR . For instance, you can retrieve a cat-
egory that meets either of these conditional expressions:
 
Search WWH ::




Custom Search