模糊查询,查询总数时,报空指针异常 public Pagemodel FindUserLike(String keword, int offset, int pagesize) throws SQLException{ System.out.println("keword=="+keword); String hql = "from User as u where u.userName like '"+keword+"'"; Query query = this.getSession().createQuery(hql); // query.setString(0, "%"+keword+"%"); int total = ((Long)query.uniqueResult()).intValue(); System.out.println("total:" + total); List datas = this.getSession().createQuery("from User") .setFirstResult(offset) .setMaxResults(pagesize).list();