Chapter 9. Criteria API

In the last chapter, we looked in detail at the JP QL query language and the concepts that underlie the JPA query model. In this chapter, we will look at an alternate method for constructing queries that uses a Java programming language API instead of JP QL or native SQL.

We will begin with an overview of the JPA 2.0 criteria API and look at a common use case involving constructing dynamic queries in an enterprise application. This will be followed by an in-depth exploration of the criteria API and how it relates to JP QL.

A related feature of the criteria API is the JPA 2.0 metamodel API. We will conclude this chapter with an overview of the metamodel API and look at how it can be used to create strongly typed queries ...

Get Pro JPA 2: Mastering the Java™ Persistence API 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.