<?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">
<!-- 写sql语句 -->
<mapper namespace="jun">
<!-- 通过id 查询一个用户 -->
<select id="findUserById" parameterType="Integer" resultType="cn.lijin.mybatis.pojo.User">
select * from user where id=#{lijun}
</select>
<!-- 根据用户名称模糊查询 -->
<select id="findUserByUsername" parameterType="String" resultType="cn.lijin.mybatis.pojo.User">
select * from user where username like "%"#{lijun}"%"
</select>
<!-- 添加用户 -->
<insert id="inserUser" parameterType="cn.lijin.mybatis.pojo.User">
insert into user(username,birthday,address,sex) values (#{username},#{birthday},#{address},#{sex})
</insert>
<!-- 更新操 -->
<update id="lijun666" parameterType="cn.lijin.mybatis.pojo.User">
update user
set username= #{username},sex= #{sex},birthday= #{birthday},address= #{address}
where id=#{id}
</update>
<!-- 删除掉 -->
<delete id="deleteUser" parameterType="Integer">
delete from user
where id= #{jun}
</delete>
</mapper>
原文:https://www.cnblogs.com/yanglin666/p/10591291.html