문제

I am wondering if there is something like the CONCAT_WS method in JPQL as I found it in the MYSQL documentation here:

http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat-ws

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top