查询当天的数据
public List<OJBMatch> getTopMatchesForCandidate(final CandidateProfileType profile, final int top, final boolean order) {
HibernateCallback callback = new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
String query = "from OJBMatch " +
"where candidateProfile = ? " +
" and displayDate >= ? and displayDate < ? " +
"order by matchDate desc";
if (order) {
query += ", score desc";
}
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Date begin = cal.getTime();
cal.add(Calendar.DATE, 1);
Date end = cal.getTime();
List<Object> list = session
.createQuery(query)
.setFetchSize(top)
.setMaxResults(top)
.setInteger(0, profile.getDbId())
.setDate(1, begin)
.setDate(2, end)
.list();
return list;
}
};
return (List<OJBMatch>) hibernateTemplate.execute(callback);
}