欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

DetachedCriteria查询实例

程序员文章站 2022-04-05 10:29:36
...
项目中用到了DetachedCriteria,顺便记下来
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]
相关标签: Blog