background image

SELECT Clause

<< NULL Values | Aggregate Functions in the SELECT Clause >>
<< NULL Values | Aggregate Functions in the SELECT Clause >>

SELECT Clause

The query language treats compared values as if they were Java types and not as if they
represented types in the underlying data store. For example, if a persistent field could be either
an integer or a NULL, then it must be designated as an Integer object and not as an int
primitive. This designation is required because a Java object can be NULL but a primitive cannot.
Two strings are equal only if they contain the same sequence of characters. Trailing blanks are
significant; for example, the strings 'abc' and 'abc ' are not equal.
Two entities of the same abstract schema type are equal only if their primary keys have the same
value.
Table 27­8
shows the operator logic of a negation, and
Table 27­9
shows the truth values
of conditional tests.
TABLE 27­8
NOT
Operator Logic
NOT Value
Value
T
F
F
T
U
U
TABLE 27­9
Conditional Test
Conditional Test
T
F
U
Expression IS TRUE
T
F
F
Expression IS FALSE
F
T
F
Expression is unknown
F
F
T
SELECT
Clause
The SELECT clause defines the types of the objects or values returned by the query.
Return Types
The return type of the SELECT clause is defined by the result types of the select expressions
contained within it. If multiple expressions are used, the result of the query is an Object[], and
the elements in the array correspond to the order of the expressions in the SELECT clause, and in
type to the result types of each expression.
A SELECT clause cannot specify a collection-valued expression. For example, the SELECT clause
p.teams
is invalid because teams is a collection. However, the clause in the following query is
valid because the t is a single element of the teams collection:
SELECT t
FROM Player p, IN (p.teams) t
Full Query Language Syntax
Chapter 27 · The Java Persistence Query Language
759