spring+mybatis3.3.0进行批量insert报错
使用的框架是spring 4.1.x + mybatis-spring 1.2.3 + mybatis 3.3.0
pojo类很简单
PersonMapper.java中写了一个批量insert的方法
然后在.xml里的配置如下:
在测试这个方法时,提示下面的错误:
如果注释掉PersonMapper.java中@Param("list")这部分,则是
注意最后这部分提示不太一样,最近刚开始用mybatis,哪位大神给看看,
这个错误该怎么办
另外,对其他的select,insert方法进行测试都正确。
pojo类很简单
public class Person implements Serializable{
/**
*
*/
private static final long serialVersionUID = -8882286452255354656L;
//主键
private Long id;
private String firstname;
private String lastname;
private String school;
... ...
}
PersonMapper.java中写了一个批量insert的方法
void batchInsert( @Param("list") List<Person> persons);
然后在.xml里的配置如下:
<insert id="batchInsert" keyProperty="id" useGeneratedKeys="true" parameterType="java.util.List">
insert into person (firstName, lastName,school) values
<foreach collection="list" item="person" index="index" separator="," >
(#{person.firstName},#{person.lastName},#{person.school})
</foreach>
</insert>
在测试这个方法时,提示下面的错误:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter '__frch_person_0' not found. Available parameters are [list, param1]
如果注释掉PersonMapper.java中@Param("list")这部分,则是
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter '__frch_person_0' not found. Available parameters are [collection, list]
注意最后这部分提示不太一样,最近刚开始用mybatis,哪位大神给看看,
这个错误该怎么办
另外,对其他的select,insert方法进行测试都正确。
...全文
相关推荐
MyBatis批量插入(insert)数据操作
本文给大家分享MyBatis批量插入(insert)数据操作知识,非常不错,具有参考借鉴价值,感兴趣的朋友一起学习吧
spring中使用mybatis实现批量插入的示例代码
主要介绍了spring中使用mybatis实现批量插入的示例代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
mybatis中批量插入的两种方式(高效插入)
MyBatis是一个支持普通SQL查询,存储过程和高级映射的优秀持久层框架。这篇文章主要介绍了mybatis中批量插入的两种方式(高效插入)的相关资料,非常不错,具有参考借鉴价值,感兴趣的朋友一起看看吧
spring+mybatis下BLOB字段的图片存取代码
spring+mybatis下BLOB字段的图片存取代码,仅整理了Controller层的代码,service和dao的代码很简单,所以没有整理
mybatis插入与批量插入返回ID的原理详解
主要给大家介绍了关于mybatis插入与批量插入返回ID的原理的相关资料,文中通过示例代码介绍的非常详细,对大家学习或者使用mybatis具有一定的参考学习价值,需要的朋友们下面来一起学习学习吧


