zoukankan      html  css  js  c++  java
  • mybatis中的几个注意的地方

    1、首先定义一个sql标签,一定要定义唯一id<sql id="Base_Column_List" >name,age</sql>
    2、然后通过id引用
    <select id="selectAll">
    select
    <include refid="Base_Column_List" />
    from student
    </select>
    这个<include refid="Base_Column_List" />会自动把上面的代码贴过来。

    <trim prefix="(" suffix=")" suffixOverrides="," >
    </trim>
    3.<trim prefix="" suffix="" suffixOverrides="" prefixOverrides="">
      <insert id="insertSelective" parameterType="com.dearbinge.data.pojo.Security" >
        <!--
          WARNING - @mbggenerated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        insert into t_security
        <trim prefix="(" suffix=")" suffixOverrides="," >
          <if test="fSecuritykey != null" >
            f_SecurityKey,
          </if>
          <if test="fSecurityvalue != null" >
            f_SecurityValue,
          </if>
          <if test="fMerchantid != null" >
            f_MerchantId,
          </if>
          <if test="fTag != null" >
            f_Tag,
          </if>
          <if test="fIsdelete != null" >
            f_IsDelete,
          </if>
          <if test="fCreateuser != null" >
            f_CreateUser,
          </if>
          <if test="fCreatetime != null" >
            f_CreateTime,
          </if>
          <if test="fUpdateuser != null" >
            f_UpdateUser,
          </if>
          <if test="fUpdatetime != null" >
            f_UpdateTime,
          </if>
          <if test="fRemark != null" >
            f_Remark,
          </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides="," >
          <if test="fSecuritykey != null" >
            #{fSecuritykey,jdbcType=VARCHAR},
          </if>
          <if test="fSecurityvalue != null" >
            #{fSecurityvalue,jdbcType=VARCHAR},
          </if>
          <if test="fMerchantid != null" >
            #{fMerchantid,jdbcType=VARCHAR},
          </if>
          <if test="fTag != null" >
            #{fTag,jdbcType=VARCHAR},
          </if>
          <if test="fIsdelete != null" >
            #{fIsdelete,jdbcType=INTEGER},
          </if>
          <if test="fCreateuser != null" >
            #{fCreateuser,jdbcType=VARCHAR},
          </if>
          <if test="fCreatetime != null" >
            #{fCreatetime,jdbcType=DATE},
          </if>
          <if test="fUpdateuser != null" >
            #{fUpdateuser,jdbcType=VARCHAR},
          </if>
          <if test="fUpdatetime != null" >
            #{fUpdatetime,jdbcType=DATE},
          </if>
          <if test="fRemark != null" >
            #{fRemark,jdbcType=VARCHAR},
          </if>
        </trim>
      </insert>
    

      

    </trim>
    prefix:在trim标签内sql语句加上前缀。
    suffix:在trim标签内sql语句加上后缀。
    suffixOverrides:指定去除多余的后缀内容,如:suffixOverrides=",",去除trim标签内sql语句多余的后缀","。
    prefixOverrides:指定去除多余的前缀内容
    当一个人在成长过程中,慢慢的享受学习,那么这个人就在成长,在往自己目标的方向奔跑.
  • 相关阅读:
    MySQL_01 常用命令
    32_Go基础(TCP通信)
    oracle查询优化
    Eclipse中自动添加注释(作者,时间)
    java注解的学习
    JqueryeasyUIdatagrid参数之 queryParams
    Eclipse中,打开文件所在文件夹的插件,及设置
    更改Zend Studio/Eclipse代码风格主题
    JAVA中使用File类批量重命名文件及java.io.File的常见用法
    java面试笔试题大全
  • 原文地址:https://www.cnblogs.com/zique/p/7786838.html
Copyright © 2011-2022 走看看