Hibernate 的QBC语法 DetachedCriteria !~
?
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 nullExpression.isNll()不为空is not nullExpression.isNotNull()在指定范围between andExpression.betweed()不再指定范围内的属性值not between andExpression.not(Expression.betweed())属性值属于指定集合inExpression.in()属性值不属于指定集合not inExpression.not(Expression.in())与andExpression.and()或orExpression.or()非notExpression.not()模糊查询likeExpression.like()?
Expression.like("name","%"+dept.getName+"%");