如何解决hibernate查询java.lang.IllegalArgumentException:遍历的节点不能为null?

时间:2015-10-20 01:12:31

标签: hibernate exception web hql

我仍然无法解决这个问题,我看到很多答案都说有错误的语法,但我觉得没问题。我的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();
    }

enter image description here

1 个答案:

答案 0 :(得分:0)

您的hql无效:from CardVoucher c where c.businessId=:businessId应为select c from CardVoucher c where c.businessId=:businessId