Example Queries

The following queries are from the PlayerBean entity bean of the RosterApp J2EE application, which is documented in Chapter 27. To see the relationships between the beans of the RosterApp, see Figure 27-3, page 967.

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 PlayerBean entity bean. Because the bean defines the findall ...

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