A.2. EJB QL enhancements

The EJB QL language was discussed in Chapter 13. In that chapter, it was suggested that the language had a number of weaknesses that needed to be addressed. EJB 2.1 addresses some of these weaknesses, but not all.

EJB QL enhancements include the following.

Support for sorting It is now possible to include an ORDER BY clause in the query. For example:

SELECT OBJECT(o) from book o 
  WHERE o.publisher = ?1 
  ORDERBY o.title 

This results in a Collection of book EJBs sorted in ascending alphabetical order of title.

Support for aggregate functions There will be support for SELECT COUNT, etc. So we can get the number of book EJBs like this:

SELECT COUNT(o) frombooko 

There is also proposed support for average (AVG), minimum ...

Get Applied Enterprise JavaBeans™ Technology 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.