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 8396617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:34:56+00:00 2026-06-09T20:34:56+00:00

I am using JPA named queries for Loading a Lazy Loaded DataTable. and setting

  • 0

I am using JPA named queries for Loading a Lazy Loaded DataTable. and setting first and Max results as shown below.

Query query = entityManager.createNamedQuery("StudyplanCategory.findByStatusAndLimit");
int end=(start*pageNumber);
query.setParameter("status", status);
query.setParameter("start", start);
query.setParameter("end", end);
query.setMaxResults(end - start);

The load method is given below:

public List<StudyplanCategory> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String,String> filters) {  
                List<StudyplanCategory> data = new ArrayList<StudyplanCategory>();
                //System.out.println("Page First Value:"+first+"PageSize Value:"+pageSize);
                datasource=categoryService.findDynaEditStudyPlan("NOT_USER_SPECIFIC",first,pageSize);
                //filter  
                for(StudyplanCategory studyplanCategory : datasource) {  
                    boolean match = true;  
                    for(Iterator<String> it = filters.keySet().iterator(); it.hasNext();) {  
                        try {  
                            String filterProperty = it.next();  
                            String filterValue = filters.get(filterProperty).toLowerCase();  
                            String fieldValue = String.valueOf(studyplanCategory.getClass().getDeclaredField(filterProperty).get(studyplanCategory)).toLowerCase();  
                            //System.out.println("fieldValue............."+fieldValue);
                            if(filterValue == null || fieldValue.startsWith(filterValue)) {  
                                match = true;  
                            }  
                            else {  
                                match = false;  
                                break;  
                            }  
                        } catch(Exception e) {  
                            match = false;  
                            System.out.println("The Exception occured at"+e);
                        }   
                    }  

                    if(match) {  
                        data.add(studyplanCategory);  
                    }  
                }  

                //sort  
                if(sortField != null) {  
                    Collections.sort(data, new LazySorter(sortField, sortOrder));  
                }  

                //rowCount  
                int dataSize = data.size();  
                this.setRowCount(dataSize);  

                //paginate  
                if(dataSize > pageSize) {  
                    try {  
                        return data.subList(first, first + pageSize);  
                    }  
                    catch(IndexOutOfBoundsException e) {  
                        return data.subList(first, first + (dataSize % pageSize));  
                    }  
                }  
                else {  
                    return data;  
                }  
            }  

But when the table is loaded Next Buttons are not active because I am loading only those data required to load the first page. How can I Solve this.

  • 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-09T20:34:58+00:00Added an answer on June 9, 2026 at 8:34 pm

    You need to fire another query which sets the total rowcount. Basically, in LazyDataModel#load():

    public List<StudyplanCategory> load(...) {
        setRowCount(studyplanCategoryService.count());
        return studyplanCategoryService.list(...);
    }
    

    Unrelated to the concrete problem, you should actually be using Query#setFirstResult() to set the first record index.

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

Sidebar

Related Questions

I'm using eclipse indigo and am having JPA Validation Problems. My named query is:
I'm using Hibernate as JPA provider with named queries and wondered if there is
I am writing a JPA QL named query that would search for documents. This
In pom.xml I have (taken from http://struberg.wordpress.com/2012/05/10/using-jpa-in-real-projects-part-1/ ): <properties> <openjpa.sql.action>refresh</openjpa.sql.action> <database.driver.name>org.postgresql.Driver</database.driver.name> <database.connection.url>jdbc:postgresql://myURL</database.connection.url> <database.user>user</database.user> <database.password>password</database.password>
I'm using Jpa with GAE. I have an Entity with collection of sub Entity
I'm using JPA in my DAOs outside of Spring . The Spring framework defines
I'm using JPA but I'm not sure how to use it for relation between
I am using JPA and I need to make the tableName a variable. In
I've been using JPA for some time now and been in projects where we've
I am using JPA with openjpa implementation beneath, on a Geronimo application server. I

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.