java - HQL - row identifier for pagination -


Do anyone know if there are keywords for HQL to identify rows such as RQL or ROWNUM?

To execute endorsement with HQL, but I am not able to use .setMaxResult () or .setFirstResult () because I do not work directly with the session object and therefore use the query object Does not, but only make my query as a string and use the .find () method.

I tried to use LIMIT and OFFSET in my query, but it does not matter if HQL is ignoring these keywords and I'm returning the whole result.

I am also not able to use the hibernate criteria because this is not supported in my question for the "hoisting" clause.

My last resort is to restrict the result set using the ROWNUM / ROWID keyword. Is someone else having any other suggestions?

This is the situation where the hibernate shines:

with the HQ query Specific solutions

  int elements PerBlock = 10; Int page = 2; Return getSession (). CreateQuery ("Order by order Aid from some items") .setFirstResult (elementsPerBlock * (Page-1) + 1) .setMaxResults (elementsPerBlock) .list ();  

Hibernate will translate into a pattern that is interpreted by the database as its SQL bid. On Oracle, this ROUUUn & lt; X On PostGrace, it will issue a limit / offset on the MSSQL server, it will issue a top ..

For my knowledge it is not possible to get it with "pure" HQL.


Comments