mybatis 3 批量插入返回主键 Parameter 'id' not found

@Insert("")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    Integer batchActivityGift(@Param("items")List 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("")
    @Options(useGeneratedKeys = true, keyProperty = "id",keyColumn="id")
    Integer batchActiveItem(@Param("list")List items);

collection对应的值请使用list    

@Param("list")

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

转载于:https://www.cnblogs.com/lanliying/p/11007798.html

你可能感兴趣的:(mybatis 3 批量插入返回主键 Parameter 'id' not found)