background image

The Java Persistence Query Language

<< Running roster Application | Simplified Query Language Syntax >>
<< Running roster Application | Simplified Query Language Syntax >>

The Java Persistence Query Language

The Java Persistence Query Language
The Java Persistence query language defines queries for entities and their persistent state. The
query language allows you to write portable queries that work regardless of the underlying data
store.
The query language uses the abstract persistence schemas of entities, including their
relationships, for its data model, and it defines operators and expressions based on this data
model. The scope of a query spans the abstract schemas of related entities that are packaged in
the same persistence unit. The query language uses a SQL-like syntax to select objects or values
based on entity abstract schema types and relationships among them.
This chapter relies on the material presented in earlier chapters. For conceptual information,
see
Chapter 24, "Introduction to the Java Persistence API."
For code examples, see Chapters
"The persistence.xml File" on page 701
and
"Updating Data in the Database" on page 708
.
Query Language Terminology
The following list defines some of the terms referred to in this chapter.
Abstract schema
: The persistent schema abstraction (persistent entities, their state, and
their relationships) over which queries operate. The query language translates queries over
this persistent schema abstraction into queries that are executed over the database schema
to which entities are mapped.
Abstract schema type
: All expressions evaluate to a type. The abstract schema type of an
entity is derived from the entity class and the metadata information provided by Java
language annotations.
Backus-Naur Form (BNF)
: A notation that describes the syntax of high-level languages.
The syntax diagrams in this chapter are in BNF notation.
Navigation
: The traversal of relationships in a query language expression. The navigation
operator is a period.
Path expression
: An expression that navigates to a entity's state or relationship field.
27
C H A P T E R
2 7
733