Defining a WHERE Clause

As with SQL, an EJB QL WHERE clause defines a conditional expression that is used to filter the results of a query. A simple example of a WHERE clause is

SELECT OBJECT(auction) FROM EnglishAuction auction, 
  IN(auction.bids) aBid WHERE aBid.amountField > 500.0 

This modified query now limits the auctions it returns to those that have received a bid for an amount greater than $500. Identification variables, such as aBid in this case, can be referenced in a WHERE clause but they cannot be declared there.

A WHERE clause supports a number of literal types, such as the floating-point value 500.0 used in this example. You can use string, integer, floating-point, and Boolean literals in a WHERE clause. String literals must be ...

Get Special Edition Using Enterprise JavaBeans™ 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.