Java Reference
In-Depth Information
If the concatenation of u.firstName and u.lastName doesn't result in ViperAd-
min , then the condition will return FALSE .
You can use the SUBSTRING function to determine if the first three letters of
u.lastName start with VIP:
WHERE SUBSTRING(u.lastName, 1, 3) = 'VIP'
The name of each string function is a good indicator of the functional operation it can per-
form. The direct analog of string functions is arithmetic functions. We'll look at what JPQL
supports in this area next.
Arithmetic functions
Although math is rarely used to perform CRUD operations, it's useful when trying to ma-
nipulate data for reports. JPQL supports only a bare minimum set of functions in this re-
gard, and some vendors may choose to add functions to enhance their reporting capabil-
ities. As with all vendor-specific features, be aware that using them will make your code
less portable should you decide to change vendors in the future. You can use arithmetic
functions in either the WHERE or HAVING clause of JPQL. Table 11.6 lists all arithmetic
functions supported by JPQL.
Table 11.6. JPQL arithmetic functions
Arithmetic functions
Returns the absolute value of simple_arithmetic_expression
Returns the square root value of simple_ arithmet-
ic_expression as a double
Returns the result of executing the modulus operation for
num, div
MOD(num, div)
Returns the number of items in a collection
Most of the arithmetic functions are self-explanatory, such as this example of SIZE :
WHERE SIZE(c.items) = 5
This expression will return TRUE when the SIZE of c.items is 5 and FALSE otherwise.
Search WWH ::

Custom Search