Does anyone know if HQL has a keyword to identify rows such as ROWID or ROWNUM?
I would like to implement pagination with HQL but I am not able to use .setMaxResult(
this is one situation where hibernate shines:
typical solution with hql query.
int elementsPerBlock = 10;
int page = 2;
return getSession().createQuery("from SomeItems order by id asc")
.setFirstResult(elementsPerBlock * (page-1) + 1 )
.setMaxResults(elementsPerBlock)
.list();
hibernate will translate this to a pattern that is understood by the database according to its sql dialect. on oracle it will create a subselect with ROWNUM < X. on postgresql it will issue a LIMIT / OFFSET on msSQL server it will issue a TOP..
to my knowledge it is not possible to achieve this with "pure" hql.