java—使用spring数据中pgsql本机查询中的collection作为参数

5ktev3wc  于 2021-06-27  发布在  Java
关注(0)|答案(0)|浏览(208)

有没有可能把它当作一个主题?

@Query("select p as payment from Payment p" +
        " left join Payment pp on pp = p" +
        " where p.uploadData.user = :user " +
        " and p.uploadData.active = false " +
        " and p.timestamp >= :timestamp_from " +
        " and p.timestamp < :timestamp_to " +
        " and (concat(p.address.building.building, ', ',p.address.apartment) in (case when :addressNull = true then concat(p.address.building.building, ', ',p.address.apartment)  else :addressList end))" +
        " and (concat(p.account.account,'') in (case when  :accountNull = true then concat(p.account.account,'') else :accountList end))" +
        " and (concat(p.service.service,'') in (case when  :serviceNull = true then concat(p.service.service,'') else :serviceList end))")
List<Payment> findAllUsingTimestampAndFilter(@Param("user") User user,
                                             @Param("timestamp_from") ZonedDateTime from,
                                             @Param("timestamp_to") ZonedDateTime to,
                                             @Param("addressList") Collection<String> address,
                                             @Param("accountList") Collection<String> account,
                                             @Param("serviceList") Collection<String> service,
                                             @Param("addressNull") boolean addressFlag,
                                             @Param("accountNull") boolean accountFlag,
                                             @Param("serviceNull") boolean serviceFlag);

当我以这种方式使用它时,当任何集合参数中包含多个项时,就会出现一个错误。

org.postgresql.util.PSQLException: ERROR: CASE types record and text cannot be matched
Position: 1061

已经试过了

...(:serviceNull or (p.service.service in :serviceList))

又犯了一个错误。
简化,我尝试了很多东西,但还是会出错。有人知道怎么解决吗?
p、 对不起,如果我的帖子有错误,这是我第一个关于stackoverflow的问题,我的英语不太好。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题