如何使用IN修复Hibernate Named Native Query的Where子句

时间:2019-08-22 01:18:45

标签: hibernate where-clause named-query

此查询将使用IN子句从数据库返回17个数据。

但是,如果我为此分配了变量,它会返回0。

有人可以帮我解决问题吗? 谢谢。

"retentionPolicy": {
          "daysToKeep" : 30, 
          "releasesToKeep": 3,
          "retainBuild": true
         },
``` @NamedNativeQuery(name = "CustomerPayeeTransaction.getCustomerPayeeTransactionsForTotalTransactionEmail", query = "" +
            "  select cpt.merchant_id, cpt.merchant_transaction_id, cpt.created_datetime, cpt.amount " +
            "  from customer_payee_transactions cpt"+
            "  inner join appl_inte_payment_gateway aipg on cpt.payment_gateway_id = aipg.integrated_payment_gateway_id"+
            "  inner join appl_cus_paye_trx_statuses acpts on cpt.cus_paye_trx_status_id = acpts.cus_paye_trx_status_id"+
            "  where (cpt.payment_gateway_id = :ipgId)"+
            "  and (acpts.name in ('CG_Pending'))")

1 个答案:

答案 0 :(得分:0)

我在休眠状态而不是字符串中找到了答案

statusList =“('CG_Pending','PG_Pending')”;

列表statusIds = Arrays.asList(“ PG_Success”,“ CG_Pending”);

然后Hibernate自动应用所需的条件。