[jboss-user] [JBoss Seam] - Re: EntityQuery: showing last page with no results?

fernando_jmt do-not-reply at jboss.com
Tue May 8 23:11:58 EDT 2007


If you are using the query with max-results defined, then you must to extend the EntityQuery class and override the following methods as follows:




  | @Override
  |     @Transactional
  |     public long getLastFirstResult() {
  | 
  |         long page = (getResultCount() / getMaxResults()) * getMaxResults();
  |         if (page >= getResultCount())
  |             return page - getMaxResults();
  |         else
  |             return page;
  |     }
  | 
  |     @Override
  |     public boolean isNextExists() {
  |         return getResultList() != null &&
  |                 getResultCount() > (getFirstResult() != null ? getFirstResult() : 0) + getMaxResults();
  |     }
  | 
  | 

Looks like the above methods in the Query class does not take care about a paged result (or whatever I can't see). So, I made the above changes and all works fine.

HTH.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4044147#4044147

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4044147



More information about the jboss-user mailing list