代码改变世界

增,删,改 的配置文件

2019-03-24 23:17  Lign_King  阅读(149)  评论(0编辑  收藏  举报

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