ssm笔记1

mybatis的SQL语句:

<mapper namespace="cn.wh.mapper.EmployeeMapper" >
<resultMap id="BaseResultMap" type="cn.wh.pojo.Employee" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="sn" property="sn" jdbcType="VARCHAR" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="gender" property="gender" jdbcType="VARCHAR" />
<result column="depId" property="depid" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, sn, name, gender, depId
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from employee
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from employee
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="cn.wh.pojo.Employee" >
insert into employee (id, sn, name,
gender, depId)
values (#{id,jdbcType=INTEGER}, #{sn,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{gender,jdbcType=VARCHAR}, #{depid,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="cn.wh.pojo.Employee" >
insert into employee
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="sn != null" >
sn,
</if>
<if test="name != null" >
name,
</if>
<if test="gender != null" >
gender,
</if>
<if test="depid != null" >
depId,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="sn != null" >
#{sn,jdbcType=VARCHAR},
</if>
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="gender != null" >
#{gender,jdbcType=VARCHAR},
</if>
<if test="depid != null" >
#{depid,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="cn.wh.pojo.Employee" >
update employee
<set >
<if test="sn != null" >
sn = #{sn,jdbcType=VARCHAR},
</if>
<if test="name != null" >
name = #{name,jdbcType=VARCHAR},
</if>
<if test="gender != null" >
gender = #{gender,jdbcType=VARCHAR},
</if>
<if test="depid != null" >
depId = #{depid,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="cn.wh.pojo.Employee" >
update employee
set sn = #{sn,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
gender = #{gender,jdbcType=VARCHAR},
depId = #{depid,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>

posted @ 2017-10-27 17:17  Calo-missile  阅读(143)  评论(0编辑  收藏  举报