Example Queries

The following queries are from the PlayerEJB entity bean of the RosterApp J2EE application, which is documented in the Chapter 6. To see the relationships between the beans of the RosterApp, see Figure 6-1 (page 121).

Simple Finder Queries

If you are unfamiliar with EJB QL, these simple queries are a good place to start.

Example 1
SELECT OBJECT(p) 
FROM Player p

Data retrieved: All players.

Finder method: findall()

Description: The FROM clause declares an identification variable named p, omitting the optional keyword AS. If the AS keyword were included, the clause would be written as follows:

FROM Player AS p 

The Player element is the abstract schema name of the PlayerEJB entity bean. Because the bean defines the findall ...

Get J2EE™ Tutorial, The 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.