-
1. Re: EntityQuery: showing last page with no results?
fernando_jmt May 8, 2007 11:11 PM (in response to hstang)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. -
2. Re: EntityQuery: showing last page with no results?
hstang May 9, 2007 11:00 AM (in response to hstang)Thanks. Have you reported this to JIRA?
-
3. Re: EntityQuery: showing last page with no results?
fernando_jmt May 9, 2007 11:08 AM (in response to hstang)Not yet. I'm tested with max-results defined. But I din't test with no max-result (not paged) defined. And also I'm thinking about to contribute some improvements, like total pages, current page, and some other minus bugs I found. When I will have this ok, I will report the errors and suggest the improvements.
-
4. Re: EntityQuery: showing last page with no results?
hstang May 9, 2007 11:31 AM (in response to hstang)Last night I already created a JIRA issue so just add to it when you are ready.
http://jira.jboss.com/jira/browse/JBSEAM-1306 -
5. Re: EntityQuery: showing last page with no results?
gavin.king May 18, 2007 9:48 PM (in response to hstang)I implemented this feature (it is something I meant to implement ages ago) in CVS. My implementation is more efficient ;-)
-
6. Re: EntityQuery: showing last page with no results?
pampam May 23, 2007 10:34 AM (in response to hstang)Hi,
I backported the changes to 1.2.1.GA, and there seams to be a small bug.
The truncateResultList should return the nr of max results and not max results -1.return results.subList(0, mr-1);
should bereturn results.subList(0, mr-1);
Robert -
7. Re: EntityQuery: showing last page with no results?
pampam May 23, 2007 10:37 AM (in response to hstang)this should of course be
return results.subList(0, mr);
-
8. Re: EntityQuery: showing last page with no results?
gavin.king May 30, 2007 3:11 PM (in response to hstang)Thanks, fixed.
Very confusing, since subList() is different to substring() in this respect :-(