Hibernate的Criteria 之条件查询
程序员文章站
2022-05-23 09:19:46
...
[url=http://www.cnblogs.com/evon168/archive/2010/10/29/1863059.html]Restrictions用法[/url]
[url=http://xuganggogo.iteye.com/blog/440078]hibernate Restrictions用法[/url]
Criteria获取记录总数示例代码:
[url=http://xuganggogo.iteye.com/blog/440078]hibernate Restrictions用法[/url]
Criteria获取记录总数示例代码:
@Override
public Long getCount(Map<String, Object> param) throws ParseException {
Date upload_time_s = DateUtils.parseDate(param.get("upload_time_s").toString(), "yyyy-MM-dd HH:mm:ss");
Date upload_time_e = DateUtils.parseDate(param.get("upload_time_e").toString(), "yyyy-MM-dd HH:mm:ss");
Criteria criteria = getSession().createCriteria(TransmitErrorRecord.class);
criteria.add(Restrictions.ge("uploadTime", upload_time_s));
criteria.add(Restrictions.le("uploadTime", upload_time_e));
criteria.setProjection(Projections.rowCount());
return (Long) criteria.uniqueResult();
}