有 Java 编程相关的问题?

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

java对Spring数据的条件查询JPA在DB2(z/OS)上给出了一个417错误

我目前在Spring Data Crudepository中有以下方法签名:

@Query("SELECT c FROM Table c WHERE (:paramOne is null or c.fieldOne = :paramOne) AND (:paramTwo is null or c.fieldTwo = :paramTwo)")
    Iterable<Table> findByParamOneAndParamTwo(@Param("paramOne") Integer p1, @Param("paramTwo") Integer p2);

Hibernate将其转换为(简化):

select * where (? is null or fieldOne=?) and (? is null or fieldTwo=?)

我使用这个方法来获得一个既可以过滤表又可以返回所有记录的方法

我的问题是,当我尝试并执行存储库的方法时,会得到一个负的417(-417)Db2错误。谷歌上说这意味着

A statement string to be prepared includes parameter markers as the operands of the same operator (for example: ? > ?)

即使我的Hibernate查询没有这样做


共 (1) 个答案