zoukankan      html  css  js  c++  java
  • mybatis批量操作数据

    批量查询语句:

    List<MoiraiProductResource> selectBatchInfo(List<Long> idList);
    <!-- 批量查询 -->
      <select id="selectBatchInfo" parameterType="java.util.List" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from moirai_product_resource
        WHERE PRODUCT_ID IN
        <foreach collection="list" open="(" close=")" separator="," item="item" index="index">
          #{item}
        </foreach>
      </select>

    批量插入:

    int insertBatchInfo(List<MoiraiProductResource> listMoiraiProductResource);
     <!-- 批量添加 -->
      <insert id="insertBatchInfo" parameterType="java.util.List">
        insert into moirai_product_resource (PRODUCT_RESOURCE_ID, PRODUCT_ID, RESOURCE_ID,
        CREATETIME, CREATER)
        values
        <foreach collection="list" item="item" index="index" separator="," >
          (#{item.productResourceId,jdbcType=BIGINT}, #{item.productId,jdbcType=BIGINT}, #{item.resourceId,jdbcType=BIGINT},
          #{item.createtime,jdbcType=BIGINT}, #{item.creater,jdbcType=VARCHAR})
        </foreach>
      </insert>
  • 相关阅读:
    什么是云安全
    VMWare vForum 2013看点
    循环和数据的操作命令
    程序交互
    数据类型
    基础变量
    模块和包
    ['hello', 'sb']正则表达式
    os模块
    内置函数
  • 原文地址:https://www.cnblogs.com/chenglc/p/7834097.html
Copyright © 2011-2022 走看看