About Criteria API
JPA Criteria API Queries
Explains how to use the JPA Criteria API (CriteriaBuilder, CriteriaQuery, etc.) to build JPQL like queries. The JPA Criteria API provides an alternative way for defining JPA queries, which is mainly useful for building dynamic queries whose exact structure is only known at runtime. This page covers the following topics: JPA Cr ...
JPA Query Structure (JPQL / Criteria)
Explains the structure of a JPQL query, which consists of 6 clauses: SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY. The syntax of the Java Persistence Query Language (JPQL) is very similar to the syntax of SQL. Having a SQL like syntax in JPA queries is an important advantage because SQL is a very powerful query language and many developers are already familiar wi ...
FROM clause (JPQL / Criteria API)
Explains how to use the FROM clause and JOIN expressions in a JPA/JPQL query. The FROM clause declares query identification variables that represent iteration over objects in the database. A query identification variable is similar to a variable of a Java enhanced for loop in a program, since both are used for iteration over o ...
JPA Query Expressions (JPQL / Criteria)
Describes JPA query (JPQL / Criteria API) expressions (literals, operators and functions). 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. ...
JPA Queries
Reference (JavaDoc) of all the JPA query types, including Query, TypedQuery, CriteriaBuilder, CriteriaQuery, Tuple, Root, Expression, Order, etc. Queries are represented in JPA by the Query and TypedQuery interfaces: javax.persistence.Query javax.persistence.TypedQuery The JPA Query API section (in chapter 4 of the ObjectDB manual) provides ...
SELECT clause (JPQL / Criteria API)
Explains how to use the SELECT clause and projections in a JPA/JPQL query. The ability to retrieve managed entity objects is a major advantage of JPQL. For example, the following query returns Country objects that become managed by the EntityManager javax.persistence.EntityManager JPA interface Inte ...
Criteria Query From Elements
Reference (JavaDoc) of JPA query criteria FROM clause interfaces, including From, Root, Join and Fetch. The interfaces in this group are in use for setting a criteria query FROM clause. Criteria Query Variables The FROM clause in JPA queries (as in SQL) defines the query variables. Query variables are represented in criteria qu ...
WHERE clause (JPQL / Criteria API)
Explains how to use the WHERE clause in a JPQL query. The WHERE clause adds filtering capabilities to the FROM-SELECT structure. It is essential in any JPQL query that retrieves selective objects from the database. Out of the four optional clauses of JPQL queries, the WHERE clause is definitely the most ...
Criteria Query Expressions
Reference (JavaDoc) of JPA query expression interfaces, including Expression, Predicate, Path, ParameterExpression and Subquery. The following interfaces are in use in representing general expressions in criteria queries: javax.persistence.criteria.Expression javax.persistence.criteria.Predicate javax.persistence.criteria.Path javax.persis ...
Criteria Query Selection and Results
Reference (JavaDoc) of JPA query criteria result interfaces, including Selection, CompoundSelection, Order and Tuple. The JPA Criteria API interfaces in this group are in use for setting the SELECT and ORDER BY clauses and for representing query results as tuples. SELECT Clause Elements The content of the SELECT clause in a criteria query is represen ...