zoukankan      html  css  js  c++  java
  • 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>

  • 相关阅读:
    IDEA修改git账号及密码的方法
    深入浅出数据库索引原理
    切勿用普通for循环遍历LinkedList
    在Jquery里格式化Date日期时间数据
    Java 根据年月日精确计算年龄
    jquery判断页面元素是否存在
    js中 '枚举' 的使用
    springMVC怎么接受前台传过来的多种类型参数?(集合、实体、单个参数)
    jquery批量绑定click事件
    springMVC怎么接收日期类型的参数?
  • 原文地址:https://www.cnblogs.com/banzhuan/p/7744332.html
Copyright © 2011-2022 走看看