I want to get every nth row from the table. I can do something like this in sql:
select * from [table] where [table].row_number % n=0;
But how can I do this in hibernate using hql?
you can use the combination of setFirstResult(n)
and setMaxResults(1)
of Query class.
setting n to setFirstResult and 1 to setMaxResults can give the desired result.
check link setFirstResult and setMaxResults
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.