命名查询中带有“CONCAT”的“SUBSTR”导致异常 - “SUBSTR”的参数计数无效?

时间:2018-01-17 11:55:26

标签: java hibernate jpa named-query

我有一个用orm.xml文件编写的名称查询,该文件与persistence.xml正确链接为:

select 
    distinct b.id
from
    BEntity b, AEntity a
where 
    b.id in (:ids) 
    and (a.someColumn = b.someColumn or (concat(substr(b.someColumn, 1, 8), 'XXX') 
                                          = a.someColumn) or a.someColumn = '**') 
    and (a.beneficiaryBIC=b.beneficiaryBIC or (concat(substr(b.beneficiaryBIC, 1, 8), 'XXX') 
                                             = a.beneficiaryBIC) or a.beneficiaryBIC = '**') 

但是当我尝试执行此查询时,我收到错误:

Caused by: org.h2.jdbc.JdbcSQLException: Invalid parameter count for "SUBSTR",
           expected count: "2..3"; SQL statement:
select distinct b0_.id as col_0_0_ from TABLE_NAME_B b0_ cross join TABLE_NAME_A a1_ where 
(b0_.id in ()) and (a1_.someColumn=b0_.someColumn or (substr(b0_.someColumn||1||8)||'XXX')
=a1_.someColumn or a1_.someColumn='**') and (a1_.beneficiaryBIC=b0_.beneficiaryBIC or 
(substr(b0_.beneficiaryBIC||1||8)||'XXX')=a1_.beneficiaryBIC or a1_.beneficiaryBIC='**')

正如我所看到的,substr(b0_.someColumn, 1, 8)更改为substr(b0_.someColumn||1||8)导致此参数计数问题,但为什么,会被||替换?

0 个答案:

没有答案