Hibernate HQL query for finding entries older than 3 hours
How sh开发者_运维问答ould I go about setting up HQL condition that would select all the object who's date property is older than 3 hours from now.
This should work.
Calendar cal = Calendar.getInstance();
cal.add(Calendar.HOUR_OF_DAY, -3);
Query q = session.createQuery("from table where date < :date");
q.setCalendarDate("date", cal);
q.list();
精彩评论