如何在HQL中逃避冒号 [英] how to escape colon in HQL

查看:148
本文介绍了如何在HQL中逃避冒号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的查询条件部分如下:

I have condition part of my query as follows:

...
where foo.bar like '%:%'

查询将执行,但没有结果。我认为这是因为冒号,因为它是HQL中的保留字符。那么我怎么可以逃避它,而不发送:作为一个参数给我的查询。

the query would execute but with no result. I think it's because of the colon since it is a reserved char in HQL. So how can I escape it without sending the : as a parameter to my query.

我已经使用'%\:%'和'%\\ :%'没有成功。

I have already used '%\:%' and '%\\:%' with no success.

推荐答案

我找到了一个解决方案:q = q.replaceAll(:,'| | unistr('\\003A')||');

I found a solution: q=q.replaceAll(":","'||unistr('\\003A')||'");

这篇关于如何在HQL中逃避冒号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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