7.2. The from clause
The simplest possible EJB-QL query is of the form:
select c from eg.Cat c
which simply returns all instances of the class
eg.Cat. Unlike HQL, the select clause is not optional in EJB-QL. We don't usually need to qualify the class name, since the entity name defaults to the unqualified class name (
@Entity). So we almost always just write:
select c from Cat c
As you may have noticed you can assign aliases to classes, the
askeywork is optional. An alias allows you to refer to
Catin other parts of the query.
select cat from Cat as cat
Multiple classes may appear, resulting in a cartesian product or "cross" join.
select form, param from Formula as form, Parameter as param
It is considered good practice to name query aliases using an initial lowercase, consistent with Java naming standards for local variables (eg.