我需要帮助将一些sql转换为hibernate sql。
SQL:
String sql = "select time, hour(time) as hour, minute(time) as minute "
+ "from db where time >= DATE_ADD(now(), INTERVAL -24 HOUR) "
+ "group by 2 order by time LIMIT 500";
我使用SQLQuery添加标量。我为HQL尝试了这个:
String hql = "select time, hour(time), minute(time) from db as O "
+ "where O.time >= :time group by 2 order by O.time";
Query query = session.createQuery(hql);
query.setDate("time", calend.getTime()); //calend is a Calendar object
然而,这不起作用。错误说它是一个hql错误。