It seems to be the following syntax didn’t work. Do we have any alternate query for this?
JPA.em().createQuery(queryStr).getResultList().from(startAt).fetch(offset);
As we know, from() and fetch() will work only on JPAQueryobject and the above code will produce List instead of JPAQueryobject.
Please note that queryStr combines 2 different models.
Is there anyway to get JPAQueryobject from the above query? So that I can use from and fetch.
Could you be a little more precise about the “didn’t work” part? Do you have any error, or something like that?
On my application, I implemented some pagination features, and an example of the JPA query is this one (
Newsis one model of my application):Regarding your edit: The method
createQueryreturns aQueryobject. Thus, you can usesetFirstResult()method andsetMaxResults()instead offrom()andfetch(). Applied on your code, your query now looks like: