<?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= "Ssmy.dao.UserDao" >
<resultmap type= "Ssmy.dto.User" id= "User" >
<!--<resultmap type= "user" id= "user" > If an alias is configured in the Sprin file configuration initialization MyBatis
<!--to map the primary key field with the id attribute --
<id property= "id" column= "id" jdbctype= "INTEGER"/>
<!--Use the result property to map a non-primary key field--
<result property= "UserName" column= "UserName" jdbctype= "VARCHAR"/>
<result property= "password" column= "password" jdbctype= "VARCHAR"/>
<result property= "Truename" column= "Truename" jdbctype= "VARCHAR"/>
<result property= "email" column= "email" jdbctype= "VARCHAR"/>
<result property= "Phone" column= "Phone" jdbctype= "VARCHAR"/>
<result property= "RoleName" column= "RoleName" jdbctype= "VARCHAR"/>
</resultMap>
<!--page return type list can use the map user corresponding to the size per page of Resultmap and
<select id= "Find" resultmap= "User" parametertype= "Map" >
Select t2.* from
(select T1.*,rownum rn from T_user t1
<where>
<if test = "UserName!=null and UserName! =" >
t1.username like '% ' | | #{username,jdbctype=varchar}| | ' % '
</if>
</where>
) T2
<where>
<if test = "Start!=null and start! =" ">
<! [Cdata[and t2.rn >=#{start}]]>
</if>
<if test = "size!=null and size! =" ">
and <! [Cdata[t2.rn <=#{size}]]>
</if>
</where>
</select>
<!--Get the total number of records --
<select id= "gettotal" parametertype= "Map" resulttype= "Java.lang.Integer" >
Select COUNT (1) from T_user
<where>
<if test = "UserName!=null and UserName! =" >
userName like '% ' | | #{username,jdbctype=varchar}| | ' % '
</if>
</where>
</select>
<!--<insert id= "Createser" parametertype= "User" >
INSERT INTO News_user (id,username,password,email,usertype)
values (#{id,jdbctype=numeric},#{username,jdbctype=varchar},
#{password,jdbctype=varchar},#{email,jdbctype=varchar},1)
<selectkey resulttype= "int" order= "before" keyproperty= "id" >
Select Seq_id.nextval from dual
</selectKey>
</insert>-->
</mapper>
Springmvc+mybatis Make paged SQL statements