有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

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

我有一个用orm编写的名称查询。与persistence.xml正确链接的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) 个答案