JPA Query Expressions (JPQL / Criteria)
Query expressions are the foundations on which JPQL and criteria queries are built.
Every query consists of clauses - SELECT, FROM, WHERE, GROUP BY, HAVING and ORDER BY, and each clause consists of JPQL / Criteria query expressions.
The atomic query expressions are:
Every query expression consists of at least one atomic component. More complex query expressions are built by combining atomic expressions with operators and functions.
Operators and Functions
JPQL / Criteria queries support the following operators (in order of decreasing precedence):
- Navigation operator (.)
- Arithmetic operators:
/(division), + (addition) and
- Comparison operators:
=, <>, <, <=,>, >=, IS [NOT] NULL, [NOT] BETWEEN,
including Collection operators: [NOT] IN, IS [NOT] EMPTY, [NOT] MEMBER [OF]
and the [NOT] LIKE operator.
- Logical operators: AND, OR, NOT.
In addition, JPA queries support predefined functions, which are also described in this section.
Organization of this Section
This section contains the following pages:
- Literals in JPQL and Criteria Queries
- Paths and Types in JPQL and Criteria API
- Numbers in JPQL and Criteria Queries
- Strings in JPQL and Criteria Queries
- Date and Time in JPQL and Criteria Queries
- Collections in JPQL and Criteria Queries
- Comparison in JPQL and Criteria API
- Logical Operators in JPQL and Criteria API
Detailed explanations on how to build criteria query expressions are provided as follows:
- Literals and Dates (
- Paths, navigation and types (
- Arithmetic expressions (
- String expressions (
- Data expressions (
- Collection expressions (
- Comparison expressions (
- Logical expressions (