mybatis例子

mybatis的mapper不允许重载,因为它需要通过方法名称[不加签名]去查找需要执行的sql

1.批量删除

  <delete id="deletePlanLocations" parameterType="list" >
    delete from plan_location where uuid in
    (<foreach collection="list" item="item" separator="," index="index"> 
        #{item, jdbcType=VARCHAR}
    </foreach>)
  </delete>

 2.批量插入

<insert id="insertPlanLocations" parameterType="list" >
    insert into plan_location (uuid, location_name, group_id, x, 
      y, tenant_id, 
      create_time, create_user_id, update_user_id
      ) values 
    <foreach collection="list" item="item" separator="," index="index" > 
        (#{item.uuid, jdbcType=VARCHAR}, #{item.locationName,jdbcType=VARCHAR},#{item.groupId,jdbcType=INTEGER},
        #{item.x,jdbcType=DOUBLE},#{item.y,jdbcType=DOUBLE},
        #{item.tenantId,jdbcType=INTEGER},#{item.createTime,jdbcType=TIMESTAMP},
        #{item.createUserId,jdbcType=INTEGER},#{item.createUserId,jdbcType=INTEGER})
    </foreach>
  </insert>

 

你可能感兴趣的:(mybatis例子)