Pagination request to database with DataManager

Hello! I need to do the pagination with using the dataManager
I have a code like:

List<VacancyFeedback> vacancyFeedbackList = dataManager.load(VacancyFeedback.class)
        .query("select vf from VacancyFeedback vf where vf.user = :user order by vf.createTs desc limit :perPage offset :offset")
        .parameter("user", user)
        .parameter("perPage", perPage)
        .parameter("offset", (page - 1) * perPage)

But I’m getting the JpqlSyntaxException Now I know tha Jpql is not supporting such a syntax.
How could i implement the pagination with DataManager.


limit and offset are SQL keywords specific to a DBMS, you can’t use them in JPQL.
Use firstResult() and maxResults() methods of the fluent loader API.


May I ask a question here as I;m not sure. If we use CUBA browser with pagination option “ON” i.e. select row-count, then isn’t it automatically handled by CUBA behind the seen or we have to use the parameters in query?

Yes, pagination in browser screen automatically sets firstResult and maxResults of LoadContext which are later translated to appropriate SQL keywords.

1 Like