StringBuilder hql = new StringBuilder();
hql.append("from Dept e ");
hql.append("where 1=1 ");
final List params = new ArrayList();
if (Name!="") {
hql.append(" and e.Name like ?");
params.add("%"+Name+"%");
}
if (Title!="") {
hql.append(" and e.Title like ?");
params.add("%"+Title+"%");
}
Query query = session.createQuery(hql.toString());
for (int i = 0; i < params.size(); i++) {
query.setParameter(i, params.get(i));
}
query.setFirstResult((pageNum - 1)*pageSize);
query.setMaxResults(pageSize);
List<Dept> list=query.list();
return list;
hql.append("from Dept e ");
hql.append("where 1=1 ");
final List params = new ArrayList();
if (Name!="") {
hql.append(" and e.Name like ?");
params.add("%"+Name+"%");
}
if (Title!="") {
hql.append(" and e.Title like ?");
params.add("%"+Title+"%");
}
Query query = session.createQuery(hql.toString());
for (int i = 0; i < params.size(); i++) {
query.setParameter(i, params.get(i));
}
query.setFirstResult((pageNum - 1)*pageSize);
query.setMaxResults(pageSize);
List<Dept> list=query.list();
return list;