select e from (select e from table_name e order by e.refid desc) as table_name e where (rownum) between :satrt and :end
i get the error as " org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: ( near line 1, column 15 "
Hibernate query : FROM table_name where rownum between :start and :end order by refid desc
works fine . but the row number order gets varied .
kindly suggest how to write the hibernate query .
This is the MySQL query to get result according to your requirement where row number order will not be varied.
Same be can achieve in hibernate with in easy way without writing such sub queries by using Query defined methods. This hibernate code will produce same result set of above sql query.