mybatis 新增判断空


mybatis 动态新增

<insert id="insertSelective" parameterType="com.yimayhd.snscenter.client.domain.ComentDO" useGeneratedKeys="true" keyProperty="id" >

    insert into com_coment
    <trim prefix="(" suffix=")" suffixOverrides="," >
      domain,
      status,
      <if test="gmtCreated != null" >
        gmt_created,
      </if>
      <if test="gmtModified != null" >
        gmt_modified,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      #{domain,jdbcType=INTEGER},
      #{status,jdbcType=INTEGER},
      <if test="gmtCreated != null" >
        #{gmtCreated,jdbcType=TIMESTAMP},
      </if>
      <if test="gmtModified != null" >
        #{gmtModified,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>

你可能感兴趣的:(mybatis 新增判断空)