Springmvc+mybatis Make paged SQL statements

Source: Internet
Author: User
Tags cdata

<?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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.