1<?xml version= "1.0" encoding= "UTF-8"?>2<! DOCTYPE Mapper Public "-//mybatis.org//dtd mapper 3.0//en" "Http://mybatis.org/dtd/mybatis-3-mapper.dtd" >3 4<!--================== Agent mode =================5Starting with the mapper tag, by/Mapper End, you can think of it as a space, a mapping file6 attribute namespace: The space name, which is used primarily in proxies. The namespace is the only one. 7The mapper tag and interface are linked together, namespace=Write interface path, map file to and interface in the same directory8-9<mapper namespace= "Com.dao.UserinfoDAO" >Ten<!--============= mapping relationship label ============= One Property Type: Write the package name Class name of the Po class, because the alias of the PO class was previously defined, this alias is written here A attribute ID: is the unique identifier for this mapping label - ID tags are unique identities in query result sets - Property Column: Queried column name the Attribute property: Is the column name specified in the PO class - is usually underlined after the original column name, which is fixed, this is the ID after _ -- -<resultmap type= "Com.po.UserinfoPO" id= "Userinfomap" > +<result column= "userid" property= "userid"/> -<result column= "LoginName" property= "LoginName"/> +<result column= "Loginpass" property= "Loginpass"/> A<result column= "username" property= "username"/> at<result column= "Upower" property= "Upower"/> -<result column= "Birthday" property= "Birthday"/> -<result column= "Sex" property= "sex"/> -</resultMap> -<!--================== Defining SQL Fragments ============== -SQL: is the SQL Fragment Label property ID is the unique identifier of the fragment-- in<sql id= "ZD" > - Userid,loginname,loginpass,username,upower,birthday,sex to</sql> +<!--Delete and change the ID in the label: Be sure to match the corresponding method name in the interface, - Resultmap The ID in the write map tag in the output type theParameterType: input type, canonical input data type, indicating the type of parameter used when querying *<!--Verify Login- $<select id= "Login" resultmap= "Userinfomap" parametertype= "Com.po.UserinfoPO" >Panax Notoginseng<!--introduce SQL fragments with an include tag, refID write id,where tags that define SQL fragments don't write in the fragment-- -Select <include refid= "Zd"/>From userinfo the<where> +Loginname=#{loginname} and Loginpass=#{loginpass} A</where> the</select> + -<!--query user list-- $<select id= "userlist" resultmap= "Userinfomap" parametertype= "Com.po.UserinfoPO" > $<!--introduce SQL fragments with an include tag, refID write id,where tags that define SQL fragments don't write in the fragment-- -Select <include refid= "Zd"/>From userinfo -</select> the -<!--query to modify the ID of the user information--Wuyi<select id= "UpdateID" resultmap= "Userinfomap" parametertype= "Com.po.UserinfoPO" > the<!--introduce SQL fragments with an include tag, refID write id,where tags that define SQL fragments don't write in the fragment-- -Select <include refid= "Zd"/>From userinfo Wu<where>userid=#{userid}</where> -</select> About $<!--Modify user information-- -<update id= "Update" parametertype= "Com.po.UserinfoPO" > - Update UserInfo -Set Loginname=#{loginname},loginpass=#{loginpass},username=#{username}, Aupower=#{upower},birthday=#{birthday},sex=#{sex} +where userid=#{userid} the</update> - $<!--Add user information-- the<insert id= "Insert" parametertype= "Com.po.UserinfoPO" > theInsert INTO UserInfo (<include refid= "Zd"/>) the Values the (#{userid},#{loginname},#{loginpass},#{username},#{upower},#{birthday},#{sex}) -</insert> in the<!--additions and deletions change the ID in the tag: Be sure to match the corresponding method name in the interface-- the<delete id= "Delete" parametertype= "int" > AboutDelete from UserInfo where userid=#{userid} the</delete> the the<!--based on the user name fuzzy query, according to the permissions query-- +<select id= "Select" resultmap= "Userinfomap" parametertype= "Java.util.Map" > -<!--introduce SQL fragments with an include tag, refID write id,where tags that define SQL fragments don't write in the fragment-- theSelect <include refid= "Zd"/>From userinfoBayi<!--when the page does not enter a user name and select permissions, let its conditions always true, it becomes a full query-- the<where> the<iftest= "username = = null and username =" and upower = =-1 "> -and 1=1 -</if> the<ifTest= "Username! = null and Username! =" "> theand username like '%${username}% ' the</if> the<ifTest= "Upower! =-1" > -and upower=#{upower} the</if> the</where> the</select>94</mapper>
Follow-up-----
Add, delete, change, check, and so on in the Mapper.xml file in the SSM framework