import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
Restrictions的幾個常用限定查詢方法如下表所示:
方法 |
說明 |
Restrictions.eq |
等于 |
Restrictions.allEq |
使用Map,使用key/value进行多个比对 |
Restrictions.gt |
大于 > |
Restrictions.ge |
大于等于 >= |
Restrictions.lt |
小于 < |
Restrictions.le |
小于等于 <= |
Restrictions.between |
对应SQL的BETWEEN子句 |
Restrictions.like |
对应SQL的LIKE子句 |
Restrictions.in |
对应SQL的in子句 |
Restrictions.and |
and关系 |
Restrictions.or |
or关系 |
Restrictions.sqlRestriction |
SQL限定关系 |
detachedCriteria.add(Restrictions.or(Restrictions.between("arttime", beforetwo,afterone),Restrictions.eq("arttype", 1))); detachedCriteria.addOrder(Order.desc("arttype")).addOrder(Order.desc("artid"));
List re = articlesDAO.findAllByCriteria(detachedCriteria);
|
阅读(2994) | 评论(0) | 转发(0) |