HQL查询两个日期间记录
hql查询两个日期间的记录是下面那样吗?为什么报错
@Test public void secondTest() throws ParseException{ String hql = "select new Map(c.name as name,o.tradedate as tradedate,o.status as status,o.amount as amount) " +"from Customer c,Orderform o " +"where o.tradedate between ? and ? and o.status in('已发货','已付款') and o.price > 1000 " +"order by o.status asc,o.tradedate desc,o.price desc"; Query query = session.createQuery(hql); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date date1 = sdf.parse("2015-05-01"); Date date2 = sdf.parse("2015-06-01"); query.setDate(0, date1); query.setDate(1, date2); List<Map> results = query.list(); for(Map r:results){ System.out.println("商品名称:"+r.get("0")); System.out.println("交易日期:"+r.get("1")); System.out.println("交易状态:"+r.get("2")); System.out.println("交易金额:"+r.get("3")); } }