Java Reference
In-Depth Information
Temporal functions
Most languages provide functions that retrieve the current date, time, or timestamp. JPQL
offers the temporal functions shown in table 11.7 . These functions translate into database-
specific SQL functions, and the requested current date, time, or timestamp is retrieved from
the database.
Table 11.7. JPQL temporal functions
Temporal functions
Description
CURRENT_DATE
Returns current date
CURRENT_TIME
Returns current time
CURRENT_TIMESTAMP
Returns current timestamp
Note that because JPQL time values are retrieved from the database, they may vary slightly
from the time retrieved from your JVM if they aren't both running on the same server. This
is an issue only if you have a time-sensitive application. You can resolve this issue by run-
ning a time service on all servers that are part of your environment. Next, we'll look at the
SELECT clause of JPQL.
11.1.3. SELECT clause
Although you saw some examples of the SELECT clause at the beginning of this chapter,
we avoided a detailed discussion of the SELECT clause until now. From the previous ex-
amples it's evident that the SELECT clause denotes the result of the query. Here's the JPQL
syntax of a SELECT clause:
SELECT [DISTINCT] expression1, expression2, .... expressionN
A SELECT clause may have more than one identifier variable, one or more single-value
path expressions, or aggregate functions separated by commas. Earlier you used an identi-
fier in the SELECT clause as follows:
SELECT c
FROM Category AS c
You can also use one or more path expressions in the SELECT clause:
 
Search WWH ::




Custom Search