Java 通过多个参数进行查询
我正在做一个在线信用充值申请。 我想按凭证的类别、类型和面额从数据库中获取凭证。 我需要有关在createQuery()和setparameter()方法中插入的查询的帮助。 这是我获取凭证的代码片段Java 通过多个参数进行查询,java,mysql,hibernate,jakarta-ee,Java,Mysql,Hibernate,Jakarta Ee,我正在做一个在线信用充值申请。 我想按凭证的类别、类型和面额从数据库中获取凭证。 我需要有关在createQuery()和setparameter()方法中插入的查询的帮助。 这是我获取凭证的代码片段 public String getVoucherPinByCategoryTypeDeno(String category, String type, double denomination) { return (String) sessionFactory.getCurrentS
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();
}
您需要这样的查询
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();
我想这张优惠券不是一张支票String@AlmoullimDev. php?这是javaxD@nachokk哦那我一定是疯了对不起