1
我一直在試圖找到一種方法來查詢我的表中的所有日期,其中修改日期早於7天。休眠查詢日期大於
這裏是我不得不在工作,但它不會工作:
@SuppressWarnings({ "unchecked", "rawtypes" })
public List<Ownership> findOwnersByDate() {
log.debug("finding a filtered list of Ownerships");
Session session = getSessionFactory().getCurrentSession();
try {
session.beginTransaction();
Criteria crit = session.createCriteria(Ownership.class)
.add(Restrictions.gt("modDate", new Integer(7)));
List results = crit.list();
log.debug("get filtered ownerships successful,
result size: " + results.size());
return results;
} catch (RuntimeException re) {
log.debug("query failed", re);
log.error("get filtered ownerships failed", re);
throw re;
}
}
嘗試把日期/日曆對象的'GT()',而不是一個整數,無論使用何種類型的'modDate'是。 –