This iBatis feature is deprecated and discarded from iBatis library. moreover it has performance issue, hence i’m striking out this blog post
thanks for visiting this post.
iBatis has very good pagination support. every query can be limited by max number of rows and scrollable.
for example i have executed “queryForPaginatedList( “queryName”, domainObject, MAX_ROWS ) “;
iBatis PaginatedList class is extension of “java.util.List” class. so you can generally use it as collection object.
following methods are added to PaginatedList class:
int getPageSize();
page size is current size of list (list.size() == MAX_ROWS)
boolean isFirstPage();
if page offset is 0 no “nextPage” is invoked (default state)
boolean isMiddlePage();
if between last and first offset (though did not use it, just assumption)
boolean isLastPage();
if page offset == total available page
boolean isNextPageAvailable();
if current offset is not the last offset
boolean isPreviousPageAvailable();
if current offset is not set to ’0′ i mean already (nextPage(…)) invoked.
boolean nextPage();
hit database(or cache) to load next MAX_ROWS number of items
boolean previousPage();
hit database(or cache) to load rows from certain range from current state to one step backward.
void gotoPage(int i);
move forcefully to certain page by specified offset
int getPageIndex();
return current page index(offset) number
How to paginate through your records?:
1. let’s think some one accessed your controller, you performed some retrieval task, and stored this “PaginatedList” object into session context.
2. when user request for “next” page. you just load your object from session and invoke “pgList.nextPage()”
3. when user request for “back/previous” page you just load your object from session and invoke “pgList.previousPage()”
4. and set again in session context.
5. access from view .. and render your desire UI…
regards and Eid Mubarak!!!





Hi,
i’m using Struts to build a portled to be deployed into Oracle Portal.
I’m using iBatis framework too to manage queries.
Now I want to manage pagination in my search results but I have an error when I try to set into the session my paginatedList object reference (to be read in my jsp page):
Action Servlet code:
—————————–
PaginatedList myList = queryExecutor.queryForPaginatedList(“myQuery”, null, 10);
HttpSession session=request.getSession();
session.setAttribute(“myList”, myList);
When it executes the third line of this code I get this error:
Error: java.lang.IllegalArgumentException: Only java.io.Serializable, javax.ejb.EJBObject and javax.ejb.EJBHome instances can be bound to a session in a distributable web-application, not: com.ibatis.sqlmap.engine.mapping.statement.PaginatedDataList@5cc942 (class com.ibatis.sqlmap.engine.mapping.statement.PaginatedDataList).
Detail: com.evermind.server.http.EvermindHttpSession.setAttribute(EvermindHttpSession.java:97)
Cause: null
How can I put in session my PaginatedList object?
Many thanks for your help
David
I get an error when putting this object into session:
Errore: java.lang.IllegalArgumentException: Only java.io.Serializable, javax.ejb.EJBObject and javax.ejb.EJBHome instances can be bound to a session in a distributable web-application, not: com.ibatis.sqlmap.engine.mapping.statement.PaginatedDataList@5cc942 (class com.ibatis.sqlmap.engine.mapping.statement.PaginatedDataList).
Bro if you have time have a look at the source code of PaginatedList implementation. It basically does pagination after retrieving the whole list which actually even we can do
.
Using this approach can lead to performance issues if the dataset is large. Also according to iBatis documentation “All paginated list features have been deprecated”. Please look into
java.util.List queryForList(java.lang.String id, int skip, int max)
The applications do need paginating function. I am disappointed that iBatis does not solve the problem instead to have the individual developers to find their own solutions. They just shift the burden to the developers. The problem still exists. The framework is supposed to solve the problem, not ignore it.