我一直在尝试找到一种方法来查询我的表中修改日期超过 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;
}
}