Udo Held Udo Held - 1 year ago 162
Java Question

JPA concat operator

Is there a JPA concat operator for string concatenation?

I know there is a JPA

function, however its ugly to use for concatenating multiple strings.


Vendors like Oracle offer
some other like Microsoft offer
. Is there a standard JPA concatenation operator so that I could create a query like

cola || colb || colc || cold

I tried
using openjpa with SQL Server, however it seems to be invalid JPQL. I couldn't find anything regarding such an operator in an oracle reference.

Answer Source

The CONCAT function was extended in JPA 2.0 to allow passing more than 2 parameters, from section (String Functions) of the specification:

CONCAT(string_primary, string_primary {, string_primary}* )

In JPA 1 this was restricted to exactly two parameters.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download