As well as supporting direct field and relation comparisons, JPQL supports a pre-defined set of functions that you can apply.
CONCAT(string1, string2): Concatenates two
string fields or literals. For example:
select x from Magazine x where concat(x.title, 's') = 'JDJs'
SUBSTRING(string, startIndex, length):
Returns the part of the string argument
starting at startIndex (1-based) and ending
at length characters past
startIndex.
select x from Magazine x where substring(x.title, 1, 1) = 'J'
TRIM([LEADING | TRAILING | BOTH] [character FROM]
string: Trims the specified character from
either the beginning (LEADING)
end (TRAILING) or both (
BOTH) of the string argument. If no trim character is
specified, the space character will be trimmed.
select x from Magazine x where trim(both 'J' from x.title) = 'D'
LOWER(string): Returns the lower-case of the
specified string argument.
select x from Magazine x where lower(x.title) = 'jdj'
UPPER(string): Returns the upper-case of the
specified string argument.
select x from Magazine x where upper(x.title) = 'JAVAPRO'
LENGTH(string): Returns the number of
characters in the specified string argument.
select x from Magazine x where length(x.title) = 3
LOCATE(searchString, candidateString [,
startIndex]): Returns the first index of
searchString in
candidateString. Positions are 1-based.
If the string is not found, returns 0.
select x from Magazine x where locate('D', x.title) = 2
ABS(number): Returns the absolute value of
the argument.
select x from Magazine x where abs(x.price) >= 5.00
SQRT(number): Returns the square root of
the argument.
select x from Magazine x where sqrt(x.price) >= 1.00
MOD(number, divisor): Returns the modulo of
number and divisor.
select x from Magazine x where mod(x.price, 10) = 0