我仍然无法解决这个问题,我看到很多答案都说有错误的语法,但我觉得没问题。我的hibernate
版本为4.3.8.Final
这是我的程序
String hql = "from CardVoucher c where c.businessId=:businessId";
Map<String,Object> params = new HashMap<String,Object>();
params.put("businessId", businessId);
vouchers = voucherDao.find(hql, params, page, rows);
public List<T> find(String hql, Map<String, Object> params, int page, int rows) {
Query q = this.getCurrentSession().createQuery(hql);
if (params != null && !params.isEmpty()) {
for (String key : params.keySet()) {
q.setParameter(key, params.get(key));
}
}
return q.setFirstResult((page - 1) * rows).setMaxResults(rows).list();
}
答案 0 :(得分:0)
您的hql无效:from CardVoucher c where c.businessId=:businessId
应为select c from CardVoucher c where c.businessId=:businessId