1:例子
public Paginate getList0(Paginate paginate) { DetachedCriteria criter = DetachedCriteria.forClass(Paginate .class); DetachedCriteria criterForTotalResults = DetachedCriteria.forClass(Paginate .class); criter.add(Expression.eq("dealed", new Boolean(false))); Calendar c = Calendar.getInstance(); c.add(Calendar.DATE, -10); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); criter.add(Expression.ge("createtime", c.getTime())); Paginate .setTotalResults(this.getTotalResults(criterForTotalResults)); List<ComStudy> list = this.getHibernateTemplate().findByCriteria(criter, paginate.getFirstResult(), Paginate .getPageSize()); Paginate .setResults(list); return Paginate ; }
2:参照
大于等于 | >= | Expression.ge() |
大于 | > | Expression.gt() |
小于等于 | <= | Expression.le() |
小于 | < | Expression.lt() |
等于 | = | Expression.eq() |
不等于 | <> | Expression.ne() |
为空 | is null | Expression.isNll() |
不为空 | is not null | Expression.isNotNull() |
在指定范围 | between and | Expression.betweed() |
不再指定范围内的属性值 | not between and | Expression.not(Expression.betweed()) |
属性值属于指定集合 | in | Expression.in() |
属性值不属于指定集合 | not in | Expression.not(Expression.in()) |
与 | and | Expression.and() |
或 | or | Expression.or() |
非 | not | Expression.not() |
模糊查询 | like | Expression.like() |
Expression.like("name","%"+dept.getName+"%");