首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >HQL QuerySyntaxException

HQL QuerySyntaxException
EN

Stack Overflow用户
提问于 2018-02-09 08:20:09
回答 1查看 94关注 0票数 0

我是一位经验丰富的SQL开发人员,刚接触到HQL,我的任务是用HQL编写跟踪并收到后续错误,它不喜欢CASE语句,但我不知道为什么。SQL查询工作良好,但已指示用户必须使用HQL。如果你可以的话,请帮忙

由: org.hibernate.hql.internal.ast.QuerySyntaxException:意外的AST节点:第1行附近的情况,第143列[从FuelStation选择fs作为fs加入fs.address作为一个fs.marketRegion =:fs.marketRegion=:fs.marketRegion和.

查询:

代码语言:javascript
复制
String hql = "Select fs from FuelStation as fs join fs.address as a where fs.marketRegion = :marketRegion "
+ "and (  (case when  :phone1 is not null "
+ "         then (    a.phone1 is not null "
+ "               and upper(translate(:phone1,  ' ()+-/@&''.,;$','')) = "
+ "                   upper(translate(a.phone1, ' ()+-/@&''.,;$','')) "
+ "               and (   (    :fsloc is not null "
+ "                        and :fsname is not null "
+ "                        and a.locality is not null "
+ "                        and fs.stationName is not null "
+ "               add upper(translate(:fsloc,         ' ()+-/@&''.,;$','')) = "
+ "                   upper(translate(a.locality,     ' ()+-/@&''.,;$','')) "
+ "               and upper(translate(:fsname,        ' ()+-/@&''.,;$','')) = "
+ "                   upper(translate(fs.stationName, ' ()+-/@&''.,;$',''))) "
+ "                    or (    a.zip is not null "
+ "                        and :fszip is not null "
+ "                        and :fsaddr is not null "
+ "                        and a.address is not null "
+ "                        and upper(translate(:zip,  ' ()+-/@&''.,;$','')) = "
+ "             and upper(translate(a.zip,            ' ()+-/@&''.,;$','')) "
+ "             and upper(translate(:fsaddr,' 0123456789()+-/@&''.,;$','')) = "
+ "             upper(translate(a.address,  ' 0123456789()+-/@&''.,;$',''))))) "
+ "         else (    a.zip is not null "
+ "              and :fszip is not null "
+ "              and :fsloc is not null "
+ "              and :fsname is not null "
+ "              and :fsaddr is not null "
+ "              and a.address is not null "
+ "              and a.locality is not null "
+ "              and fs.stationName is not null "
+ "              and upper(translate(a.zip,          ' ()+-/@&''.,;$','')) = "
+ "                  upper(translate(:fszip,         ' ()+-/@&''.,;$','')) "
+ "              and upper(translate(:fsloc,         ' ()+-/@&''.,;$','')) = "
+ "                  upper(translate(a.locality,     ' ()+-/@&''.,;$','')) "
+ "              and upper(translate(:fsname,        ' ()+-/@&''.,;$','')) = "
+ "                  upper(translate(fs.stationName, ' ()+-/@&''.,;$','')) "
+ "            and upper(translate(:fsaddr,  ' 0123456789()+-/@&''.,;$','')) = "
+ "                upper(translate(a.address,' 0123456789()+-/@&''.,;$',''))) "
+ "         end) "
+ "      or "
+ "        (     abs(abs(a.latitude)  - abs(:lat)) <= 0.001 "
+ "          and abs(abs(a.longitude) - abs(:lng)) <= 0.001)) ";
EN

回答 1

Stack Overflow用户

发布于 2018-02-15 20:49:43

@伯纳德;蜂巢在口译方面有困难;或者。或者,在翻译功能中。相反,尝试在特殊字符之前添加转义字符。希望能帮上忙。谢谢。

代码语言:javascript
复制
Old: upper(translate(:phone1,  ' ()+-/@&''.,;$',''))
New: upper(translate(:phone1,  ' ()+-/@&''\.\,\;$',''))

我正在使用Apache (版本1.2)

代码语言:javascript
复制
sample: select upper(translate('1+2\;)3(456',  ' ()+-/@&''\.\,\;$',''));
result: 123456
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48701452

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档