![](https://csdnimg.cn/release/download_crawler_static/10535028/bg5.jpg)
JPA 101: Java Persistence Explained
J P Q L
P
AGE 157
. . . . .
Here, the identification variables are u and r. r represents any Role that is directly reachable from a User instance.
R
E S E R V E D
I D E N T I F I E R S
The JPA defines the following reserved identifiers (even though the list below is shown in uppercase, reserved
identifiers are case insensitive, so
SELECT is the same as select or SelECt):
SELECT, FROM, WHERE, UPDATE, DELETE, JOIN, OUTER, INNER, LEFT, GROUP, BY, HAVING, FETCH, DISTINCT,
OBJECT, NULL, TRUE, FALSE, NOT, AND, OR, BETWEEN, LIKE, IN, AS, UNKNOWN, EMPTY, MEMBER, OF, IS, AVG,
MAX
, MIN, SUM, COUNT, ORDER, BY, ASC, DESC, MOD, UPPER, LOWER, TRIM, POSITION, CHARACTER_LENGTH,
CHAR_LENGTH
, BIT_LENGTH, CURRENT_TIME, CURRENT_DATE, CURRENT_TIMESTAMP, NEW, EXISTS, ALL, ANY,
SOME.
UNKNOWN is not currently used in the JPQL.
P
A T H
E X P R E S S I O N S
A path expression is defined as an identification variable followed by the navigation operator (.) followed by a
state-field or an association-field. You can traverse relationships as long as they are not collections. Figure 7.1
shows a portion of the
agoraBB object model and is used to help explain path expressions.
Figure 7.1: Path expression example model
The PrivateMessage to User relationship is represented by the PrivateMessage association-field toUser. User
has a collection association-field to
Roles called roles and another to UserIpAddress called userIpAddress.
Given these relationships, you can perform the following navigations:
• PrivateMessage to User to UserIpAddresses
SELECT p.toUser.userIPAddresses from PrivateMessage p