hql语句中Calendar类型数据怎么比较大小?

如题:
假如数据库有一张表,表中的一个字段的类型是Calendar类型,现在我需要根据这个字段查询日期在当前时间之前的记录,应该怎么去编写HQL语句(主要问题是不知怎么在hql语句中比较Calendar类型字段的大小),大家一起讨论一下啊,加班到现在还没想出来怎么去写,悲哀啊... :cry:

[quote]Query query = sess.createQuery("from MyTable where myDate>=:begin and myDate<:end");;//我的意思myDate是Calendar类型的,这么做行吗? [/quote]

直接 Calendar 没试过! 如果可以就考虑转成 Date

我们这么干:
Calendar cal = Calendar.getInstance();;

cal.setTime(date);;

cal.set(Calendar.HOUR_OF_DAY, 0);;

cal.set(Calendar.MINUTE, 0);;

cal.set(Calendar.SECOND, 0);;

cal.set(Calendar.MILLISECOND, 0);;

Date begin = cal.getTime();;

cal.add(Calendar.DATE, 1);;

Date end = cal.getTime();;

Query query = sess.createQuery("from MyTable where myDate>=:begin and myDate<:end");;

query.setDate("begin", begin);;

query.setDate("end", end);;

List list = query.list();;