大于,小于,等于,大于等于,小于等于
public List<实体类> getBetweenStartDateAndEndDate( Session session, int id, DateTime startDateTime, DateTime endDateTime) { DateTime endDate = endDateTime.plusDays(1);//查询日期必须要加1天,不然查不到今天创建的记录,要考虑23:59:59秒的问题 StringBuffer hql = new StringBuffer( "FROM 实体类 WHERE poolid = '" + id + "' AND createDt >= '" + startDateTime.toString("yyyy-MM-dd") + "' AND createDt <'" + endDate.toString("yyyy-MM-dd") + "' ORDER BY id ASC"); Query query = session.createQuery(hql.toString()); List<实体类> cps = query.list(); return cps; }