Book Image

EJB 3 Developer Guide

By : Michael Sikora
Book Image

EJB 3 Developer Guide

By: Michael Sikora

Overview of this book

Table of Contents (18 chapters)
EJB 3 Developer Guide
Credits
About the Author
About the Reviewers
Preface
Annotations and Their Corresponding Packages

Conditional Expressions


The WHERE clause is used to filter results. For example,

SELECT c FROM Customer c WHERE c.lastName = 'PAGE'

retrieves only those Customer entities with lastName equal to'PAGE'.

A large number of constructs are provided for constructing conditional expressions that make up a WHERE clause.

More than one condition can be used in a WHERE clause by means of the AND operator:

SELECT c FROM Customer c WHERE c.lastName = 'KING'
AND c.firstName = 'SIMON'

As well the = (equal) operator JPQL provides the following comparison operators:

>, >=, <, <=, <> (not equal).

The IS NULL operator tests whether or not a single-valued path expression is a NULL value:

SELECT ad FROM Address ad WHERE ad.postCode IS NULL

There is a negated version of the operator, NOT NULL as in:

SELECT ad FROM Address ad WHERE ad.postCode IS NOT NULL

The BETWEEN operator is used for checking whether a value is within a given range. BETWEEN is inclusive, so in the query:

SELECT ac FROM...