Skip to Content
Java Enterprise in a Nutshell, Third Edition
book

Java Enterprise in a Nutshell, Third Edition

by Jim Farley, William Crawford
November 2005
Intermediate to advanced
896 pages
31h 5m
English
O'Reilly Media, Inc.
Content preview from Java Enterprise in a Nutshell, Third Edition

SELECT Clause

As with standard SQL queries, the SELECT clause in EJB QL can specify what you want returned from the persistent store. The SELECT clause takes the form:

SELECT [ DISTINCT ] [ <schema variable> | <aggregation expression> ]

The clause contains a single variable reference to indicate the type of result returned by the query, or an aggregation function can be used to calculate some formula on the results. The optional DISTINCT operator specifies that the return results should be unique. The variable reference can either be to a specific variable declared in the FROM clause, or it can be a path expression that refers to a single-valued CMR field on an abstract schema type. In our previous example, we used a specific variable reference:

SELECT OBJECT(p) FROM ProfileBean AS p WHERE p.entriesBytes IS NULL

This SELECT clause specifies OBJECT(p) as the return value of the query. If a single query variable is being used in the SELECT clause, then it has to be qualified with the OBJECT operator. The p variable is declared in the FROM clause as a range variable with type ProfileBean, so the query results are one or more ProfileBeans that match the conditions in the WHERE clause. In our other query example:

SELECT DISTINCT OBJECT(prof) FROM Person p, IN(p.profiles) prof WHERE ...

the SELECT clause specifies OBJECT(prof) as the return value of the query. The prof variable is declared in the FROM clause as a collection member variable that refers to the profiles CMR field in the Person ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Java Enterprise in a Nutshell, Second Edition

Java Enterprise in a Nutshell, Second Edition

William Crawford, Jim Farley, David Flanagan
Modernizing Enterprise Java

Modernizing Enterprise Java

Markus Eisele, Natale Vinto

Publisher Resources

ISBN: 0596101422Catalog PageErrata