标签:
这段时间一直在用mybatis+spring+springMVC的框架,总结点东西吧。
mybatis的oracle分页写法:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="common">
<sql id="Oracle_Pagination_Head">
<if test="oracleStart!=null and oracleEnd!=null">
<![CDATA[select y.* from(select z.*,rownum as oracleStart from (]]>
</if>
</sql>
<sql id="Oracle_Pagination_Tail">
<if test="oracleStart != null and oracleEnd != null">
<![CDATA[ ) z where rownum <= #{oracleEnd} ) y where y.oracleStart > #{oracleStart} ]]>
</if>
</sql>
</mapper>
页面调用此方法的情况:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.edu.hbcf.plugin.asset.dao.AssetApplyDao">
<select id="queryAsset" resultType="cn.edu.hbcf.plugin.asset.pojo.AssetInfo" parameterType="Criteria">
<include refid="common.Oracle_Pagination_Head" />
select ASSET_ID as assetId,
from asset_info
where processinstanceId = #{condition.processinstanceId}
<include refid="common.Oracle_Pagination_Tail" />
</select>
mysql的分页通用代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="common">
<sql id="MySql_Pagination_Head">
</sql>
<sql id="MySql_Pagination_Tail">
<if test="limit != 0">
<![CDATA[ limit #{start},#{limit} ]]>
</if>
</sql>
</mapper>
先留下痕迹,以后用的时候方便查看
标签:
原文地址:http://www.cnblogs.com/zrui-xyu/p/4527691.html