Posted on 2006-01-11 05:01
理想 阅读(5835)
评论(2) 编辑 收藏 所属分类:
hibernate
例子为取某一天的所有数据:
1 SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
2 Date ld = df.parse("2006-01-01");
3 Calendar rd = Calendar.getInstance();
4 rd.setTime(ld);
5 rd.set(Calendar.HOUR_OF_DAY, 23);
6 rd.set(Calendar.MINUTE, 59);
7 rd.set(Calendar.SECOND, 59);
8 Query query = sessoin.createQuery("from Order where date between :l and :r");
9 query.setParameter("l", ld);
10 query.setParameter("r", rd.getTime());
11 return query.list();