@Insert("<script>INSERT INTO scp_activity_gift (activity_id,type,gift_id,status,limit_num,num)  "
+ "VALUES "
+" <foreach collection='items' item='item' separator=',' >"
+"(#{item.activityId},#{item.type},#{item.giftId},#{item.status},#{item.limitNum},#{item.num})"
+" </foreach>"
+ "</script>")
@Options(useGeneratedKeys = true, keyProperty = "id")
Integer batchActivityGift(@Param("items")List<ActivityGiftPO> items);

这个会抛异常   Parameter 'id' not found

把 useGeneratedKeys = true  改成 useGeneratedKeys = false

来自:https://www.cnblogs.com/smallstudent/p/5924213.html

https://blog.csdn.net/danchaofan0534/article/details/77095159

以上问题解决了id not  found   然而没有达到我想要的  列表返回主键id

@Insert("<script>INSERT INTO scp_active_offer_category_item (company_item_id,category_id,active_id) "
+ "VALUES "
+" <foreach collection='list' item='item' separator=',' >"
+"(#{item.companyItemId},#{item.categoryId},#{item.activeId})"
+" </foreach>"
+ "</script>")
@Options(useGeneratedKeys = true, keyProperty = "id",keyColumn="id")
Integer batchActiveItem(@Param("list")List<ActiveOfferCategoryItemPO> items);

collection对应的值请使用list

@Param("list")

来自:https://blog.csdn.net/kahhy/article/details/84248354

mybatis 3 批量插入返回主键 Parameter 'id' not found的更多相关文章

  1. mybatis批量插入返回主键问题

    今天整合mybatis时候用到返回主键问题,批量插入总是返回不了主键还报错. 记录入下: pom版本: <mybatis.version>3.2.6</mybatis.version ...

  2. mybatis 批量插入 返回主键id

    我们都知道Mybatis在插入单条数据的时候有两种方式返回自增主键: 1.对于支持生成自增主键的数据库:增加 useGenerateKeys和keyProperty ,<insert>标签 ...

  3. mybatis mysql 批量insert 返回主键

    Mybatis在插入单条数据的时候有两种方式返回自增主键:    mybatis3.3.1支持批量插入后返回主键ID, 首先对于支持自增主键的数据库:useGenerateKeys和keyProper ...

  4. MyBatis insert操作插入,返回主键from官方

    下面就是 insert,update 和 delete 语句的示例: <insert id="insertAuthor" parameterType="domain ...

  5. mybatis获取批量插入的主键自增id

    一.写一个实体类 public class UserInfo { private long userId; private String userAccount; private String use ...

  6. Mybatis批量insert 返回主键值和foreach标签详解

    Mybatis批量insert 返回主键 Mybatis从3.3.1版本开始,支持批量插入后返回主键ID.首先对于支持自增主键的数据库使用useGenerateKeys和keyProperty,对于不 ...

  7. mybatis添加记录时返回主键id

    参考:mybatis添加记录时返回主键id 场景 有些时候我们在添加记录成功后希望能直接获取到该记录的主键id值,而不需要再执行一次查询操作.在使用mybatis作为ORM组件时,可以很方便地达到这个 ...

  8. mybatis注解版in查询、字符串判空模糊匹配 、批量插入、插入返回主键

    IN查询 @Select({"<script> " + " select * "+ " from business_threat bt \ ...

  9. hao947 : Mybatis resultMap配置插入和主键自增返回 : 好947

    映射配置文件  好947  <!-- type:映射实体类的数据类型 id:resultMap的唯一标识 -->  <resultMap type="person" ...

随机推荐

  1. JAVA并发工具类---------------(Fork/Join)

    Fork/Join 分而治之 将一个大任务分成数个小任务执行,然后将这些小人物执行后的结果进行join汇总: (假设:你要计算1到1000的总和,你可以把它分成1-100,101-200,...... ...

  2. sublime text3 nodejs控制台输出结果中文乱码

    在sublime text3安装完nodejs的插件后,运行console.log("你好"),发现控制台出现中文乱码,解决办法:Preferences-> Browser ...

  3. C语言变长参数实现

    #include<stdio.h> #include<string.h> #include<stdarg.h> /***编写可变长参数列表的函数案例*/ /* vo ...

  4. fatal error C1076: compiler limit : internal heap limit reached; use /Zm to specify a higher limit

    最近想用一下Xtreme ToolkitPro 界面库,安装后用VC6根据向导 产生一个工程,编译时出现如下的错误: fatal error C1076: compiler limit : inter ...

  5. 专题:NFSv4 file server

    Network File System (NFS) is a file system protocol that allows client machines to access network at ...

  6. 天道神诀---FTP服务

    FTP 2种模式 主动模式(默认) 客户端以1024-65535之间某一端口发送指令到服务端的21端口,并建立连接.服务端接受到以后,以20端口去连接客户端,建立一条新的链接并传输数据 被动模式 客户 ...

  7. pytest_按标记执行

    import pytest@pytest.mark.webtestdef test_send_http(): pass @pytest.mark.apptestdef test_devide(): p ...

  8. 2019-8-31-dotnet-通过-HttpClient-下载文件同时报告进度的方法

    title author date CreateTime categories dotnet 通过 HttpClient 下载文件同时报告进度的方法 lindexi 2019-08-31 16:55: ...

  9. Pregel 消息传递机制

  10. tf.matmul() 和tf.multiply() 的区别

    1.tf.multiply()两个矩阵中对应元素各自相乘 格式: tf.multiply(x, y, name=None) 参数: x: 一个类型为:half, float32, float64, u ...