开发者

Hibernate HQL query for finding entries older than 3 hours

开发者 https://www.devze.com 2023-02-16 02:32 出处:网络
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.

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();
0

精彩评论

暂无评论...
验证码 换一张
取 消