hibernate 时间比较 hql

直接上例子吧


@SuppressWarnings("unchecked")
@Override
public List queryActionTopTen() {
try {
Date date=Calendar.getInstance().getTime();
String hql = "from AuctionItemEntity ai where ai.auctionEvent.startTime<=:date and ai.closed=false and ai.rejected=true ORDER BY RAND()";
Query query = getHibernateTemplate().getSessionFactory()
.openSession().createQuery(hql);
query.setTimestamp("date", date);
query.setFirstResult(0);
query.setMaxResults(10);
List lst = (List) query
.list();
return lst;
} catch (Exception e) {
e.printStackTrace();
}


return null;
}

你可能感兴趣的:(hibernate 时间比较 hql)