1、条件查询采用离线条件查询的方法
/**
* 条件查询
*/
public List<Dep> getList(Dep dep1) {
DetachedCriteria dc = DetachedCriteria.forClass(Dep.class);
if(null != dep1) {
//是否输入部门名称
if(null != dep1.getName() && dep1.getName().trim().length() > 0) {
//MatchMode.ANYWHERE 任意位置匹配
//MatchMode.END 结尾匹配
//MatchMode.START 开始匹配
dc.add(Restrictions.like("name", dep1.getName(),MatchMode.ANYWHERE));
}
//是否输入部门的电话
if(null != dep1.getTele() && dep1.getTele().trim().length() > 0) {
//MatchMode.ANYWHERE 任意位置匹配
//MatchMode.END 结尾匹配
//MatchMode.START 开始匹配
dc.add(Restrictions.like("tele", dep1.getTele(),MatchMode.ANYWHERE));
}
}
return (List<Dep>) this.getHibernateTemplate().findByCriteria(dc);
}
/**
* 条件查询
*/
p