0

我正在做一个在线信用充值申请。我想按类别、类型和面额从数据库中获取凭证。我需要有关在 creatquery() 和 setparameter() 方法中插入的查询的帮助。这是我获取优惠券的代码片段。

public String getVoucherPinByCategoryTypeDeno(String category, String type, double denomination) {
        return (String) sessionFactory.getCurrentSession().createQuery("from voucher v where v.category = :category and v.voucherType = :type and v.denomination = :denomination").setparameter().uniqueResult();
    }
4

1 回答 1

2

你需要这样的查询

Voucher voucher = (Voucher) session.createQuery("from Voucher v where v.category = :category and v.voucherType = :type and v.denomination = :denomination")
.setString("category", category)
.setString("voucherType", type)
.setDouble("denomination", denomination)
.uniqueResult();
于 2013-07-03T15:14:35.390 回答