The Java Persistence Query Language provides the CONCAT() function, so you should be able to write Obj2.value1 || Obj2.value2
as CONCAT(Obj2.value1, Obj2.value2)
What is the equivalent of '||' (concat) in Entitymanager java query?
-
02-07-2022 - |
Question
I would like to rewrite an oracle stored procedure to java code, to select data with concatenated values in a query string to compare the following way:
Query qString =
"SELECT Obj " +
"FROM MyTable Obj2 WHERE ( Obj2.value1 || Obj2.value2 ) in " +
"(SELECT Obj2.value1 || MAX(Obj2.value2) FROM MyTable Obj2 WHERE Obj2.value2 >= :param GROUP BY Obj2.value1) " +
"ORDER BY Obj.value2, Obj.value1";
query = entityManager.createQuery(qString);
query.setParameter("param ", param );
When I run the query as a webservice on weblogic server I got error with the '|' character. What can I use instead of the || operator to get the same result?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow