Submitted by Lizhe on Thu, 06/08/2017 - 18:01


<mapper namespace="com.test">

    <sql id="paginationPrefix">
        <if test="filter != null and paginated == true">
            select * from (select rownum rn_, q_.* from (

    <sql id="paginationSuffix">
        <if test="filter != null and paginated == true">
            ) q_ where rownum &lt; #{maxRowToFetch}) where rn_ &gt;= #{minRowToFetch}





    <select id="findByFilter" parameterType="com.test.Filter" resultMap="searchDto">
        <include refid="com.test.paginationPrefix" />
        select * from Table
        <include refid="searchOutageFilterWhereClause" />
        <include refid="com.test.paginationSuffix" />
    <select id="countByFilter" parameterType="com.test.Filter" resultType="int">
        select count(*) as cnt from Table
        <include refid="searchWhereClause" />


    <sql id="searchOutageFilterWhereClause">