ObjectDB ObjectDB

Chapter 4 - JPA Queries (JPQL / Criteria)

The JPA Query Language (JPQL) can be considered as an object oriented version of SQL. Users familiar with SQL should find JPQL very easy to learn and use. This chapter explains how to use JPQL as well as how to use the JPA Criteria API, which provides an alternative way for building queries in JPA, based on JPQL.

The first section describes the API that JPA provides for using dynamic and static (named) queries. It explains how to use the relevant interfaces, annotations, enums and methods, but does not provide specific details on the JPQL query language itself:

The Java Persistence Query Language (JPQL) is discussed in the next two sections. First, the structure of a JPQL query (and a criteria query) is explained by describing the main clauses of JPQL queries (SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY):

Then the expressions that are used for building JPQL and criteria query clauses are explained:

ObjectDB also supports the Java Data Objects (JDO) Query Language (JDOQL), which is more Java oriented and is based on the syntax of Java. JDOQL is not covered in this manual (see chapter 7 in ObjectDB 1.0 manual for a description JDOQL).