我是一位经验丰富的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和.
查询:
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)) ";发布于 2018-02-15 20:49:43
@伯纳德;蜂巢在口译方面有困难;或者。或者,在翻译功能中。相反,尝试在特殊字符之前添加转义字符。希望能帮上忙。谢谢。
Old: upper(translate(:phone1, ' ()+-/@&''.,;$',''))
New: upper(translate(:phone1, ' ()+-/@&''\.\,\;$',''))我正在使用Apache (版本1.2)
sample: select upper(translate('1+2\;)3(456', ' ()+-/@&''\.\,\;$',''));
result: 123456https://stackoverflow.com/questions/48701452
复制相似问题