IBatis分页配置
IBatis分页方法我没去看,这里讲的分页为通过SQL语句来分页。
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd"> <sqlMap> <!-- 定义别名 --> <typeAlias alias="user" type="com.szli.vo.EsbAdminUserInfo" /> <typeAlias alias="pager" type="com.szli.vo.Pager" /> <resultMap id="query_user_map" class="user"> <result property="userId" column="USERID" javaType="java.lang.Long" jdbcType="NUMBER"></result> <result property="userName" column="USERNAME" javaType="java.lang.String" jdbcType="VARCHAR2"></result> <result property="passWord" column="PASSWORD" javaType="java.lang.String" jdbcType="VARCHAR2"></result> <result property="email" column="EMAIL" javaType="java.lang.String" jdbcType="VARCHAR2"></result> <result property="status" column="STATUS" javaType="java.lang.Integer" jdbcType="NUMBER"></result> <result property="lastLoginTime" column="LASTLOGINTIME" javaType="java.util.Date" jdbcType="DATE"></result> <result property="failCount" column="FAILCOUNT" javaType="java.lang.Integer" jdbcType="NUMBER"></result> <result property="lockTime" column="LOCKTIME" javaType="java.util.Date" jdbcType="DATE"></result> <result property="tenantId" column="TENANT_ID" javaType="java.lang.String" jdbcType="VARCHAR2"></result> <result property="skin" column="SKIN" javaType="java.lang.String" jdbcType="VARCHAR2"></result> <result property="userGroup.groupId" column="GROUPID" javaType="java.lang.Long" jdbcType="NUMBER"></result> <result property="userGroup.groupName" column="GROUPNAME" javaType="java.lang.String" jdbcType="VARCHAR2"></result> <result property="userGroup.status" column="STATUS" javaType="java.lang.Integer" jdbcType="NUMBER"></result> <result property="userGroup.description" column="DESCRIPTION" javaType="java.lang.String" jdbcType="VARCHAR2"></result> <result property="userGroup.groupType" column="GROUPTYPE" javaType="java.lang.Integer" jdbcType="NUMBER"></result> </resultMap> <select id="query_user_by_map" resultMap="query_user_map" parameterClass="java.util.HashMap"> <![CDATA[ SELECT * FROM (SELECT ROWNUM r,in_ui.* FROM esb_admin_user_info in_ui WHERE ROWNUM <= #ENDROWNUM#) ui, esb_admin_group_info gi WHERE ui.GROUPID = gi.GROUPID AND ui.r >= #STARTROWNUM# ]]> <isNotEmpty property="USERINFO"> <isNotEmpty prepend="AND" property="USERINFO.userName"> USERNAME LIKE #USERINFO.userName# </isNotEmpty> <isNotEmpty property="USERINFO.userGroup"> <isGreaterThan prepend="AND" property="USERINFO.userGroup.groupId" compareValue="0"> gi.GROUPID = #USERINFO.userGroup.groupId# </isGreaterThan> </isNotEmpty> </isNotEmpty> </select> </sqlMap>Dao层传递过来的是一个Map集合,而Map集合中又包括查询条件与起始行‘STARTROWNUM’、总共需要多少行‘ENDROWNUM’(这两个值是由当前页与页大小算出来的:
Map<String,Object> params = new HashMap<String, Object>(); params.put("USERINFO", userInfo); params.put("STARTROWNUM", (pageCurrent-1)*pageSize+1); params.put("ENDROWNUM",(pageCurrent-1)*pageSize+pageSize);).
相关推荐
Dullonjiang 2020-01-23
与卿画眉共浮生 2011-06-25
yierxiansheng 2014-06-18
登峰小蚁 2019-12-24
plane 2017-10-19
踩风火轮的乌龟 2019-10-23
pandapanda 2014-05-08
阿泰 2014-07-02
shouen 2016-04-26
whileinsist 2012-04-07
spprogrammer 2018-01-25
Coohx 2017-12-05
AndroidOliver 2012-05-14
BruceWayne 2014-12-02
liubang000 2014-05-30
KOJ 2013-11-26
CXC0 2013-08-28