码迷,mamicode.com
首页 > 移动开发 > 详细

Mybatis的mapper.xml文件也是要加文件头的

时间:2018-05-28 16:52:13      阅读:275      评论:0      收藏:0      [点我收藏+]

标签:birt   use   模糊查询   enc   ima   rtu   ast   coding   value   

<?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="com.itheima.mybatis.mapper.UserMapper">
<!-- 通过ID查询一个用户 -->
<select id="findUserById" parameterType="Integer" resultType="User">
select * from user where id = #{v}
</select>

<!-- //根据用户名称模糊查询用户列表
#{} select * from user where id = ? 占位符 ? == ‘五‘
${} select * from user where username like ‘%五%‘ 字符串拼接

-->
<select id="findUserByUsername" parameterType="String" resultType="com.itheima.mybatis.pojo.User">
select * from user where username like "%"#{haha}"%"
</select>

<!-- 添加用户 -->
<insert id="insertUser" parameterType="com.itheima.mybatis.pojo.User">
<selectKey keyProperty="id" resultType="Integer" order="AFTER">
select LAST_INSERT_ID()
</selectKey>
insert into user (username,birthday,address,sex)
values (#{username},#{birthday},#{address},#{sex})
</insert>

<!-- 更新 -->
<update id="updateUserById" parameterType="com.itheima.mybatis.pojo.User">
update user
set username = #{username},sex = #{sex},birthday = #{birthday},address = #{address}
where id = #{id}
</update>

<!-- 删除 -->
<delete id="deleteUserById" parameterType="Integer">
delete from user
where id = #{vvvvv}
</delete>


</mapper>

Mybatis的mapper.xml文件也是要加文件头的

标签:birt   use   模糊查询   enc   ima   rtu   ast   coding   value   

原文地址:https://www.cnblogs.com/zjj1996/p/9100759.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!