iBatis PaginatedList and pagination

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!!!

Advertisements

7 responses to “iBatis PaginatedList and pagination

  1. David

    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

  2. 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).

  3. 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 :).

  4. 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)

  5. 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.

  6. Hello, i feel that i noticed you visited my weblog thus i got here to return
    the desire?.I’m trying to in finding things to improve my site!I suppose its ok to use some of your ideas!!

  7. I’m very happy to discover this web site. I need to to thank you for ones time for this particularly wonderful read!! I definitely enjoyed every part of it and I have you saved as a favorite to check out new information on your blog.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

my tweets

October 2006
S S M T W T F
« Sep   Nov »
 123456
78910111213
14151617181920
21222324252627
28293031  

Flickr Photos

RSS my shared links on google reader

  • An error has occurred; the feed is probably down. Try again later.
%d bloggers like this: