mybatis Mapper下insert和insertSelective的区别

insert(所有字段全部插入)

 
    insert into address (idaddress, name, add, 
      create_time, ts, iduser, phoneno
      )
    values (#{idaddress,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{add,jdbcType=VARCHAR}, 
      #{createTime,jdbcType=DATE}, #{ts,jdbcType=DATE}, #{iduser,jdbcType=VARCHAR}, #{phoneno,jdbcType=VARCHAR}
      )
  

insertselective(不为null字段全部插入)

id="insertSelective" parameterType="org.share.domain.dao.info.Address">
    insert into address
    "(" suffix=")" suffixOverrides=",">
      <if test="idaddress != null">
        idaddress,
      if>
      <if test="name != null">
        name,
      if>
      <if test="add != null">
        add,
      if>
      <if test="createTime != null">
        create_time,
      if>
      <if test="ts != null">
        ts,
      if>
      <if test="iduser != null">
        iduser,
      if>
      <if test="phoneno != null">
        phoneno,
      if>
    
    "values (" suffix=")" suffixOverrides=",">
      <if test="idaddress != null">
        #{idaddress,jdbcType=VARCHAR},
      if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      if>
      <if test="add != null">
        #{add,jdbcType=VARCHAR},
      if>
      <if test="createTime != null">
        #{createTime,jdbcType=DATE},
      if>
      <if test="ts != null">
        #{ts,jdbcType=DATE},
      if>
      <if test="iduser != null">
        #{iduser,jdbcType=VARCHAR},
      if>
      <if test="phoneno != null">
        #{phoneno,jdbcType=VARCHAR},
      if>
    
  

你可能感兴趣的:(Java基础篇)