我想将oracle存储过程重写为java代码,在查询字符串中选择具有连接值的数据,以便比较以下方式:
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 );
当我在weblogic服务器上运行查询作为web服务时,我收到错误的'|'字符。 我可以用什么来代替||运算符得到相同的结果?
答案 0 :(得分:3)
Java持久性查询语言提供CONCAT()函数,因此您应该能够将Obj2.value1 || Obj2.value2
写为CONCAT(Obj2.value1, Obj2.value2)