Hitachi

uCosminexus Application Server Compatibility Guide


9.17.1 JPQL syntax

A JPQL statement includes the SELECT statement, UPDATE statement, and DELETE statement.

You can dynamically specify a JPQL statement or statically define a JPQL statement using the annotation and O/R mapping file tags. You can also specify parameters in all the JPQL statements.

JPQL is a typed language and all the expressions have a type. The abstract schema type defined in the expression configuration and the identification variable, the type for evaluating the persistence fields and relationships, and the literal type configure the expression types. For details on the syntax, see Appendix G BNF for JPQL.

Important note

In Cosminexus JPA Provider, an exception might occur if you use JPQL that does not conform to the BNF syntax. Even if an exception does not occur, the operation might not function properly. Also, even if you use JPQL that conforms to the BNF syntax, the operations might not function properly if the relevant functionality is not supported in the database used.

Organization of this subsection

(1) Abstract schema type

With JPQL, a query is issued for an entity. Therefore, the abstract schema of the target entity must be defined with the query. The abstract schema type of the entity is defined based on the entity class and O/R mapping information provided by the annotations or the O/R mapping file.

The abstract schema type indicates an entity class. The fields and the O/R mapping information of the annotation configure the entity class.

The abstract schema type of the entity has the following fields:

(2) Abstract schema name

With JPQL, you must specify the abstract schema type in order to indicate an entity. The name used for indicating the abstract schema type is called the abstract schema name. You define the abstract schema name in the name attribute of @Entity (or in the name attribute of the <entity> tag in the O/R mapping file). If the name attribute is not specified, the name becomes the class name of the entity class (without package name).

The abstract schema name is specific to each persistence unit.

(3) Query domain

The query domain can reference the abstract schema type of all the entities defined in the persistence unit. The abstract schema type of the other related entities can be referenced using the relation field defined in the abstract schema type.