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.  JavaServerTM Faces Technology

5.  Introduction to Facelets

6.  Unified Expression Language

7.  Using JavaServerTM Faces Technology in Web Pages

8.  Using Converters, Listeners and Validators

9.  Developing With JavaServerTM Faces Technology

10.  Java Servlet Technology

Part III Web Services

11.  Introduction to Web Services

12.  Building Web Services with JAX-WS

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

Part IV Enterprise Beans

14.  Enterprise Beans

15.  Getting Started with Enterprise Beans

16.  Running the Enterprise Bean Examples

Part V Contexts and Dependency Injection for the JavaTM EE Platform

17.  Introduction to Contexts and Dependency Injection for the JavaTM EE Platform

18.  Running the Basic Contexts and Dependency Injection Examples

Part VI Persistence

19.  Introduction to the Java Persistence API

20.  Running the Persistence Examples

21.  The Java Persistence Query Language

Query Language Terminology

Creating Queries Using the Java Persistence Query Language

Named Parameters in Queries

Positional Parameters in Queries

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

Case Expressions

NULL Values

Equality Semantics

SELECT Clause

Return Types

The DISTINCT Keyword

Constructor Expressions

ORDER BY Clause

The GROUP BY Clause

The HAVING Clause

22.  Creating Queries Using the Criteria API

Part VII Security

23.  Introduction to Security in the Java EE Platform

24.  Getting Started Securing Enterprise Applications

25.  Getting Started Securing Web Applications

Part VIII JavaTM EE Supporting Technologies

26.  Introduction to JavaTM EE Supporting Technologies

27.  Transactions

28.  Resource Connections

Index

 

Simplified Query Language Syntax

This section briefly describes the syntax of the query language so that you can quickly move on to the next section, Example Queries. When you are ready to learn about the syntax in more detail, see the section Full Query Language Syntax.

Select Statements

A select query has six clauses: SELECT, FROM, WHERE, GROUP BY, HAVING, and ORDER BY. The SELECT and FROM clauses are required, but the WHERE, GROUP BY, HAVING, and ORDER BY clauses are optional. Here is the high-level BNF syntax of a query language query:

QL_statement ::= select_clause from_clause 
  [where_clause][groupby_clause][having_clause][orderby_clause]

The SELECT clause defines the types of the objects or values returned by the query.

The FROM clause defines the scope of the query by declaring one or more identification variables, which can be referenced in the SELECT and WHERE clauses. An identification variable represents one of the following elements:

  • The abstract schema name of an entity

  • An element of a collection relationship

  • An element of a single-valued relationship

  • A member of a collection that is the multiple side of a one-to-many relationship

The WHERE clause is a conditional expression that restricts the objects or values retrieved by the query. Although it is optional, most queries have a WHERE clause.

The GROUP BY clause groups query results according to a set of properties.

The HAVING clause is used with the GROUP BY clause to further restrict the query results according to a conditional expression.

The ORDER BY clause sorts the objects or values returned by the query into a specified order.

Update and Delete Statements

Update and delete statements provide bulk operations over sets of entities. They have the following syntax:

update_statement :: = update_clause [where_clause] delete_statement :: = 
        delete_clause [where_clause]

The update and delete clauses determine the type of the entities to be updated or deleted. The WHERE clause may be used to restrict the scope of the update or delete operation.