Chapter 5. Querying Entities using JPQL and the Criteria API

In this chapter, we will cover:

  • Populating the Patient and Medication tables
  • Using the Select clause
  • Using the Where clause
  • Controlling the number of entities returned by a select query
  • Using the Delete query
  • Using the Update query
  • Using parameters in a query
  • Using a named query
  • Using the Criteria API

Introduction

There are two primary Java EE technologies for querying a database: Java Persistence Query Language (JPQL) and the Criteria API. JPQL is similar in appearance and usage to SQL while the Criteria API provides a more type-safe and object-oriented entity querying capability.

When using EJB 2.0, developers used EJB QL as the query language. With the introduction of J2EE 5.0, JPQL was introduced ...

Get EJB 3.1 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.