JPA concat运算符 [英] JPA concat operator

查看:710
本文介绍了JPA concat运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有用于字符串连接的JPA concat运算符?

Is there a JPA concat operator for string concatenation?

我知道有一个JPA CONCAT 函数,但是它用于连接多个字符串很难看。

I know there is a JPA CONCAT function, however its ugly to use for concatenating multiple strings.

CONCAT(CONCAT(CONCAT(cola,colb),colc),cold)

Oracle等供应商提供 || 其他像Microsoft提供 + 。是否有标准的JPA连接运算符,以便我可以创建一个查询,如

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

我尝试使用带有SQL的openjpa + 然而,服务器似乎是无效的JPQL。我在 oracle reference <中找不到关于此类运算符的任何内容/ a>。

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.

推荐答案

CONCAT 函数扩展为 JPA 2.0 允许传递超过2个参数,来自规范的4.6.17.2.1节(字符串函数):

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

CONCAT(string_primary, string_primary {, string_primary}* )

在JPA 1中,这是受限制的准确地说是两个参数。

In JPA 1 this was restricted to exactly two parameters.

这篇关于JPA concat运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆