日期:2014-05-17  浏览次数:20803 次

hibernate查询HQL问题
如下语句怎么用HQL写:
SELECT * FROM User as a, (SELECT UserID From User Order By UserName Limit 98039,20) as b
WHERE a.UserID = b.UserID

如果用Hibernate来写的话,怎么用HQL或者用XML映射解决?

------解决方案--------------------
String hql = "from User u where u.rownum < 9803920 Order By UserName ";
------解决方案--------------------
你这个好像不能用HQL,用session.createSQLQuery()一样嘛,HQL一定能转化为sql,sql不一定能转化为HQL