1. Oracle DB:
Sql: SELECT * FROM user WHERE rownum <=n;
Hql: from User u order by u.salary desc where rownum<=n;
2. SQL Server:
Sql: SELECT TOP n * FROM user;
3. MySQL:
Sql: SELECT * FROM Table1 LIMIT n
hibernate查询记录的前10条记录,Hql 不支持limit
Hql: query.setFirstResult(0); // 从第0条记录开始取
query.setMaxResults(10); // 取10条记录