background image

The IS EMPTY Expression

<< Queries with Other Conditional Expressions | Bulk Updates and Deletes >>
<< Queries with Other Conditional Expressions | Bulk Updates and Deletes >>

The IS EMPTY Expression

See also
:
"NULL Comparison Expressions" on page 754
,
"NULL Values" on page 758
The IS EMPTY Expression
SELECT p
FROM Player p
WHERE p.teams IS EMPTY
Data retrieved
: All players who do not belong to a team.
Description
: The teams relationship field of the Player entity is a collection. If a player does
not belong to a team, then the teams collection is empty and the conditional expression is TRUE.
See also
:
"Empty Collection Comparison Expressions" on page 755
The BETWEEN Expression
SELECT DISTINCT p
FROM Player p
WHERE p.salary BETWEEN :lowerSalary AND :higherSalary
Data retrieved
: The players whose salaries fall within the range of the specified salaries.
Description
: This BETWEEN expression has three arithmetic expressions: a persistent field
(p.salary) and the two input parameters (:lowerSalary and :higherSalary). The following
expression is equivalent to the BETWEEN expression:
p.salary >= :lowerSalary AND p.salary <= :higherSalary
See also
:
"BETWEEN Expressions" on page 753
Comparison Operators
SELECT DISTINCT p1
FROM Player p1, Player p2
WHERE p1.salary > p2.salary AND p2.name = :name
Data retrieved
: All players whose salaries are higher than the salary of the player with the
specified name.
Description
: The FROM clause declares two identification variables (p1 and p2) of the same type
(Player). Two identification variables are needed because the WHERE clause compares the salary
of one player (p2) with that of the other players (p1).
See also
:
"Identification Variables" on page 747
Example Queries
Chapter 27 · The Java Persistence Query Language
739