一、持久层:
Map map = new HashMap();
map.put("CurrentIndex", pageIndex);
map.put("PageSize", pageSize);
map.put("FieldSearchKey", sbParams.toString());
List rlist = getSqlMapClientTemplate().queryForList(
"getDispCardPadding", map);
二、配置文件:
<select id="getDispCardPadding" resultClass="java.util.HashMap"
parameterClass="java.util.Map" fetchSize="200">
declare @pageLowerBound int ,@pageUpperBound int Set
@pageLowerBound = (#CurrentIndex#-1) * #PageSize# Set
@pageUpperBound = @pageLowerBound + #PageSize#
<!-- 符合条件记录存储于临时表中 -->
Declare @indexTable table(id int identity(1,1), nid int) insert
into @indexTable(nid) select [CARD_IDENTITY] from viewdispassets where 1=1
<isNotNull prepend="AND" property="FieldSearchKey">
<![CDATA[$FieldSearchKey$]]>
</isNotNull>
ORDER BY [CARD_IDENTITY] DESC
<!-- 按记录数进行查询 -->
<![CDATA[
SELECT a.* from @indexTable as t inner join viewdispassets a on
t.nid = a.[CARD_IDENTITY] where t.id > @pageLowerBound and t.id <= @pageUpperBound ORDER BY t.id ASC
]]>
</select>
注:此方法是网上通用分页方式,适合中小数据量的程序使用