DetachedCriteria查询实例
程序员文章站
2022-04-05 10:29:36
...
项目中用到了DetachedCriteria,顺便记下来
PaginationSupport
[url]http://gundumw100.iteye.com/blog/473233[/url]
DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Holiday.class);
detachedCriteria.add(Restrictions.eq("department", department));
//下面这句比较复杂
detachedCriteria.add(Restrictions.or(Restrictions.ge("state", "2"), Restrictions.and(Restrictions.and(Restrictions.like("address", "%"+user.getDepartment()+"%"), Restrictions.like("department", "%"+user.getAddress()+"%")),Restrictions.ne("userId", user.getUserId()))));
detachedCriteria.add(Restrictions.ne("userId", user.getUserId()));
/排序
detachedCriteria.addOrder(Order.desc("id"));
detachedCriteria.addOrder(Order.desc("addtime"));
//分页查询
PaginationSupport pagination=this.getBaseService().findPageByCriteria(detachedCriteria, Constant.PAGESIZE, form.getStartIndex());
List list = pagination.getItems();
request.setAttribute("list", list);
request.setAttribute("pagination", pagination);
PaginationSupport
[url]http://gundumw100.iteye.com/blog/473233[/url]