zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    作业3
    学习进度
    作业2
    介绍自己,并介绍github注册过程和初步使用
    mysql显示中文乱码问题解决
    数学能力测试
    C++ Primer总结
    shell脚本
    完全二叉树
    test命令的测试功能
  • 原文地址:https://www.cnblogs.com/guochunyi/p/5179179.html
Copyright © 2011-2022 走看看