如何使用 IN 修复休眠命名本机查询的 Where 子句



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

但是如果我为此分配了变量,它会给出 0 作为回报。

有人可以帮助我出了什么问题吗? 谢谢。

``` @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'))")

```String statusList = "('CG_Pending','PG_Pending')";
query.setParameter("statusId",statusList);
@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 :statusList)")

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

状态列表 = "('CG_Pending','PG_Pending'(";

List statusIds = Arrays.asList("PG_Success","CG_Pending"(;

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

最新更新