Book Image

EJB 3 Developer Guide

By : Michael Sikora
Book Image

EJB 3 Developer Guide

By: Michael Sikora

Overview of this book

Table of Contents (18 chapters)
EJB 3 Developer Guide
Credits
About the Author
About the Reviewers
Preface
Annotations and Their Corresponding Packages

Introduction


A rather limited query language, EJB QL, was provided in EJB 2.0 and 2.1. JPQL enhances EJB QL by providing the following features: JOINs, GROUP BY, HAVING, projection, subqueries, dynamic queries, bulk update and delete. We shall see examples of all these features in this chapter.

JPQL is similar to the SQL language for querying relational databases. However, JPQL queries are expressed in Java objects rather than tables and columns. As SQL dialects differ between relational database vendors, JPQL has an added advantage of portability across databases. The entity manager uses the JDBC configuration specified in the persistence.xml file to convert the JPQL query to native SQL.

There may be occasions where potential queries cannot be expressed in JPQL, for example if we want to execute stored procedures. To account for this, JPQL provides the ability to invoke native SQL queries. However, the portability advantage of JPQL is lost in this case.