You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by meindert <me...@eduflex.com> on 2009/10/16 15:59:37 UTC

skip Results, maxResults in statement

Hi All,

 

I want to use pagination as efficient as possible. Mike Haller posted a nice
blog about it;

http://www.java-community.de/archives/86-Pagination-with-Apache-iBatis-SqlMa
ps.html

 

The problem is that I want to do the paging on the statement level, I know
that that would limit the query to one database (sql Server 2005 in my case)

But is there a way to get the values of the skipResults, maxResults
parameters in the statement?

 

At the moment i add a paging object to my POJO class, example;

<isNotNull property="paging.endRow"> top $paging.endRow$ ROW_NUMBER() OVER(

            Order by <isNull property="paging.sortBy">[default sorting
column] DESC</isNull> 

                       <isNotNull property="paging.sortBy">$sortBy$
$sortorder$</isNotNull>) as Row,

       </isNotNull>

       

    [The normal query]

   

    <isNotNull property="paging.endRow"> WHERE  Row >= #paging.startRow# AND
Row &lt;= #paging.endRow# </isNotNull> 

      ORDER BY <isNull property="paging.sortBy">[default sorting column]
DESC</isNull> 

                   <isNotNull property="paging.sortBy">$paging.sortBy$
$paging.sortorder$</isNotNull>

 

 

 

Meindert Hoving