Rittel Rittel - 4 months ago 19x
SQL Question

Is there a CONCAT_WS method in JPQL?

I am wondering if there is something like the

method in
as I found it in the
MYSQL documentation


Anyone ever stumbled over anything comparable?


No, there is not. JPQL does have following String functions: CONCAT, LENGTH, LOWER, SUBSTRING, TRIM, and UPPER. Only way in with older JPQL versions is to simply repeat separator between each value in CONCAT:

SELECT CONCAT(se.string1, ';', se.string2) 
FROM SomeEntity se

With JPQL in the JPA 2.1 specification implementations it is possible to call database functions as follows (first arguments is name of the function, others are arguments to function):

SELECT FUNCTION('CONCAT_WS', ';', se.string1, se.string2) 
FROM SomeEntity se

Older EclipseLink versions have same functionality via FUNC keyword.