Document Information

Preface

Part I Introduction

1.  Overview

2.  Using the Tutorial Examples

Part II The Web Tier

3.  Getting Started with Web Applications

4.  Java Servlet Technology

5.  JavaServer Faces Technology

6.  Introduction to Facelets

7.  Using JavaServer Faces Technology in Web Pages

8.  Developing with JavaServer Faces Technology

9.  Configuring JavaServer Faces Applications

Part III Web Services

10.  Introduction to Web Services

11.  Building Web Services with JAX-WS

12.  Building RESTful Web Services with JAX-RS and Jersey

Part IV Enterprise Beans

13.  Enterprise Beans

14.  Getting Started with Enterprise Beans

15.  Running the Enterprise Bean Examples

Part V Persistence

16.  Introduction to the Java Persistence API

17.  Running the Persistence Examples

Query Language Terminology

Simplified Query Language Syntax

Select Statements

Update and Delete Statements

Example Queries

Simple Queries

A Basic Select Query

Eliminating Duplicate Values

Using Named Parameters

Queries That Navigate to Related Entities

A Simple Query with Relationships

Navigating to Single-Valued Relationship Fields

Traversing Relationships with an Input Parameter

Traversing Multiple Relationships

Navigating According to Related Fields

Queries with Other Conditional Expressions

The LIKE Expression

The IS NULL Expression

The IS EMPTY Expression

The BETWEEN Expression

Comparison Operators

Bulk Updates and Deletes

Update Queries

Delete Queries

Full Query Language Syntax

BNF Symbols

BNF Grammar of the Java Persistence Query Language

FROM Clause

Identifiers

Identification Variables

Path Expressions

Examples of Path Expressions

Expression Types

Navigation

WHERE Clause

Literals

Input Parameters

Conditional Expressions

Operators and Their Precedence

BETWEEN Expressions

IN Expressions

LIKE Expressions

NULL Comparison Expressions

Empty Collection Comparison Expressions

Collection Member Expressions

Subqueries

Functional Expressions

NULL Values

Equality Semantics

SELECT Clause

Return Types

The DISTINCT Keyword

Constructor Expressions

ORDER BY Clause

The GROUP BY Clause

The HAVING Clause

Part VI Security

19.  Introduction to Security in the Java EE Platform

20.  Using Java EE Security

21.  Securing Java EE Applications

22.  Securing Web Applications

Part VII Java EE Supporting Technologies

23.  Introduction to Java EE Supporting Technologies

24.  Transactions

25.  Resource Connections

Index

 

Chapter 18

The Java Persistence Query Language


Note - This section has not been updated for Java EE 6.


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 16, Introduction to the Java Persistence API. For code examples, see Chapter Chapter 17, Running the Persistence Examples.