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:指定去除多余的前缀内容
    当一个人在成长过程中,慢慢的享受学习,那么这个人就在成长,在往自己目标的方向奔跑.
  • 相关阅读:
    分布式编程下的CAS
    《码农翻身》读后感
    PHP Socket服务器搭建和测试
    在Java中使用Hibernate,使用不同数据库服务名
    linq的表关系解决办法
    SilverLight中使用WCF Ria出现的问题empty domain service class
    cmd中更换用户权限
    Flex中TabBar与ViewStack
    使用ApdComPort
    拖动控件
  • 原文地址:https://www.cnblogs.com/zique/p/7786838.html
Copyright © 2011-2022 走看看