映射配置:
<?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">
<!-- namespace命名空间,防止sql语句的id重名 -->
<!-- paramterType指sql语句参数类型 -->
<!-- resultType指结果类型 -->
<mapper namespace="entity.userMapper">
<select id="selectUser" resultType="entity.User">
select * from user where
id=#{id}
</select>
<!-- resultType返回值结果类型 -->
<!-- <insert id="addUser" resultType="int"> -->
<!-- 提交参数类型:paramterType="entity.User" -->
<insert id="addUser" parameterType="entity.User">
<!-- name,pwd一定是传进来参数的属性 -->
insert into user(name,pwd,id) values(#{name},#{pwd},#{id});
</insert>
<select id="selectUserPwd" resultType="entity.User">
select * from user where
pwd=#{pwd}
</select>
<update id="updateUser" parameterType="entity.User">
update user set name=#{name},pwd=#{pwd} where id=#{id}
</update>
<delete id="deleteUser" >
delete from user where id=#{id}
</delete>
</mapper>