Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8867573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:04:29+00:00 2026-06-14T17:04:29+00:00

I am trying to implement a pagination functionality with JPA but I am having

  • 0

I am trying to implement a pagination functionality with JPA but I am having trouble.

I can get and set the first and last numbers on the link e.g. localhost:8000/?first=11&last=20.

As you can see, I am trying to get the items starting at row 11 and ending at row 20, however, I am getting all the results starting from first but with a total amount of last e.g. starting at 10 but with 20 results as opposed to the desired 10.

I am using:

query.setFirstResult(firstRowNumber - 1).setMaxResults(lastRowNumber);

How do I therefore limit my results?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:04:31+00:00Added an answer on June 14, 2026 at 5:04 pm

    You want this:

    query
      .setFirstResult(firstRowNumber - 1)
      .setMaxResults(lastRowNumber - firstRowNumber + 1);
    

    Notice that the method is named setMaxResults() (total number), not setLastResult(). Have a look at awesome spring-data-jpa which handles paging very nicely.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying to implement pagination. A set of 9 products are displayed at
I'm trying to implement pagination in my Rails 3 app with Kaminari but I'm
I am trying to implement the previous page functionality for pagination, and I thought
I am new to both MVC and Stackoverflow I am trying to implement pagination
Hi people thanks for the help. Im trying to implement a simple pagination that
I'm trying to implement pagination using App Engine's RPC and GWT (it's an app
Im trying to implement the endless pagination jquery plugin found here ( https://github.com/jney/jquery.pageless )
I'm trying to implement some simple paging, based on How do I do pagination
I am trying to implement pagination in my search results with Yii. I have
How can I implement pagination using Doctrine_Pager or sfDoctrinePager while my query selects multiple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.