逃避结肠“:”在Hibernate / Postgres / JSON中 [英] Escaping colon ":" in Hibernate/Postgres/JSON
问题描述
在直SQL中,以下工作方式与预期的一样:
sb.append(select ...< blah>,regexp_split_to_table(fe.meta :: json->>'elementName' ',')...
我尝试过将:: json可以在网上找到。
sb.append(select ...< blash> regexp_split_to_table(fe.meta \\\:\\:json->>'elementName',',')...
:\\:
\\
使用!:!:
然后添加逃避!
无论组合如何,我都会获得无效查询,并不是所有命名参数都已设置或空格参数前缀不允许
有没有其他方法?
任何帮助非常感谢! / p>
x :: json
只是一个PostgreSQL特定的转换方式 x
到 json
,如果不想使用 ::
语法,则不必使用或者如果你不能因为有人想使用冒号来命名参数。您可以随时使用简单的旧标准 cast
:
cast(fe.meta as json ) - >'elementName'
I am trying to build up an HQL query that uses the postgress json search capabilities.
In straight SQL, the following works as expected:
sb.append("select...<blah>, regexp_split_to_table(fe.meta::json->>'elementName', ',') ...
I have tried every combination of escaping that "::json" I can find on the web.
sb.append("select...<blash>, regexp_split_to_table(fe.meta\\:\\:json->>'elementName', ',') ...
:\\:
\\::
using !:!:
and then adding escape !
Regardless of the combinations, I either get invalid query, not all named parameters have been set or Space is not allowed after parameter prefix
Is there any other method out there?
Any help greatly appreciated!
x::json
is just a PostgreSQL-specific way of casting x
to json
, you don't have to use the ::
syntax if you don't want to or if you can't because someone wants to use colons for named parameters. You can always use a plain old standard cast
instead:
cast(fe.meta as json)->>'elementName'
这篇关于逃避结肠“:”在Hibernate / Postgres / JSON中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!