public List execureQuery(String hql, Object[] param, int start, int pageSize) {
List ret = null;
try {
SQLQuery query = this.getSession().createSQLQuery(hql);
int len = param.length;
for (int i = 0; i < len; i++) {
query.setParameter(i, param);
}
query.setFirstResult(start);
query.setMaxResults(pageSize);
ret = query.list();
} catch (RuntimeException re) {
log.error("HistoryLocationDAOImpl execureQuery failed", re);
throw re;
}
return ret;
}
   public void testHql() {
HistoryLocationDAOImpl dao = new HistoryLocationDAOImpl();
List paramList = new ArrayList();
String a = "";
String b = "";
String c = "";
StringBuffer sb = new StringBuffer();
sb.append(" select * from stafferinfo where 1=1 ");
if (null != a && !"".equals(a)) {
sb.append(" and staffergender= ? ");
paramList.add(a);
}
if (null != b && !"".equals(b)) {
sb.append(" and groupid= ? ");
paramList.add(b);
}
if (null != c && !"".equals(c)) {
sb.append(" and departmentid= ? ");
paramList.add(c);
}
Object[] obj = paramList.toArray();
dao.execureQuery(sb.toString(), obj, 1, 5); }
各位的做法呢?