MyBatis 中的@Param 注解
2016-02-29 13:25
274 查看
I try to make batch insert into table at Oracle database using MyBatis (integrated with Spring) .
It is a definition of method in mapper interface:
It is a MyBatis XML mapper code:
When I execute this I receive MyBatisSystemException with message "nested exception is org.apache.ibatis.builder.BuilderException: Improper inline parameter map format. Should be: #{propName,attr1=val1,attr2=val2}"
What is wrong? How to fix it?
I found solution here
It is a definition of method in mapper interface:
public void savePayments(@Param("payments") List<MassPaymentItem> payments);
It is a MyBatis XML mapper code:
<insert id="savePayments" parameterType="MassPaymentFileItem" useGeneratedKeys="false"> INSERT INTO mass_payments (payment_id, file_id, msisdn, amount, status) <foreach collection="payments" item="payment" index="index" separator=" UNION ALL "> SELECT SEQ_MASS_PAYMENT.nextval, #{payment.fileId}, #{payment.msisdn}, #{payment.amount}, 0 FROM DUAL </foreach> </insert>
When I execute this I receive MyBatisSystemException with message "nested exception is org.apache.ibatis.builder.BuilderException: Improper inline parameter map format. Should be: #{propName,attr1=val1,attr2=val2}"
What is wrong? How to fix it?
I found solution here
<insert id="savePayments"> INSERT ALL <foreach collection="payments" item="payment"> INTO mass_payments_t (payment_id, file_id, msisdn, amount) VALUES (seq_mass_payment.nextval, #{payment.fileId, javaType=Integer, jdbcType=NUMERIC}, #{payment.msisdn, javaType=String, jdbcType=VARCHAR}, #{payment.amount, javaType=BigDecimal, jdbcType=NUMERIC}) </foreach> SELECT * FROM dual </insert>
相关文章推荐
- 深入浅析mybatis oracle BLOB类型字段保存与读取
- MyBatis MapperProvider MessageFormat拼接批量SQL语句执行报错的原因分析及解决办法
- oracle+mybatis 使用动态Sql当插入字段不确定的情况下实现批量insert
- MyBatis学习笔记(二)之关联关系
- 浅析Mybatis 在CS程序中的应用
- Java Mybatis框架入门基础教程
- Java简单实现SpringMVC+MyBatis分页插件
- MyBatis批量添加、修改和删除
- MyBatis与Hibernate的比较
- 浅析mybatis和spring整合的实现过程
- mybatis的动态sql详解(精)
- Mybatis实现增删改查及分页查询的方法
- MyBatis入门学习教程(一)-MyBatis快速入门
- Spring与Mybatis的整合方法有哪些
- 详解MyBatis直接执行SQL查询及数据批量插入
- 解决springmvc+mybatis+mysql中文乱码问题
- Spring3.1.1+MyBatis3.1.1的增、删、查、改以及分页和事务管理
- Spring+Mybatis+Mysql搭建分布式数据库访问框架的方法
- Mybatis实战教程之入门到精通(经典)
- Mybatis与Hibernate的区别