Unable to make batch insert into Oracle DB using MyBatis
2017-12-29 20:17
459 查看
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:
public void savePayments(@Param(“payments”) List payments);
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 that the first answer doesn’t work for me, then i find another solution as below:
from: https://stackoverflow.com/questions/26278531/unable-to-make-batch-insert-into-oracle-db-using-mybatis/34398186#34398186
It is a definition of method in mapper interface:
public void savePayments(@Param(“payments”) List 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 that the first answer doesn’t work for me, then i find another solution as below:
<insert id="savePayments" parameterType="java.util.List" useGeneratedKeys="true"> <selectKey resultType="java.lang.Integer" keyProperty="payment_id" order="BEFORE"> SELECT SEQ_MASS_PAYMENT.nextval as payment_id FROM DUAL </selectKey> INSERT INTO mass_payments (payment_id, file_id, msisdn, amount, status) select SEQ_MASS_PAYMENT.nextval, A.* from ( <foreach collection="payments" item="payment" index="index" separator="UNION ALL"> SELECT #{payment.fileId} as file_id, #{payment.msisdn} as msisdn, #{payment.amount} as amount, 0 as status FROM DUAL </foreach> ) A </insert>
from: https://stackoverflow.com/questions/26278531/unable-to-make-batch-insert-into-oracle-db-using-mybatis/34398186#34398186
相关文章推荐
- mybatis oracle insert into select 命令未正确结束
- Unable to validate using XSD: Your JAXP provider [oracle.xml.jaxp.JXDocumentBuilderFactory@1e0c9f64]
- that-annoying-insert-problem-getting-data-into-the-db-using-dapper
- How to make the SSIS load infopath XML files into DB?
- OracleDBControl启动失败Unable to determine local host from URL REPOSITORY_URL=http://
- an example to insert data into Oracle Clob
- How To Convert Number into Words using Oracle SQL Query
- Tomcat上配置连接池{ connect error=Name [jdbc/OracleDB] is not bound in this Context. Unable to find [jdbc]}
- [ DB ][ SQL Server ] [C#] C# using DML to insert and update DML
- Unable to print reports as PDF files on the server using batch processing AX
- OracleDBControl启动失败Unable to determine local host from URL REPOSITORY_URL=http://your-url.co 解决方法
- Android ormlite DB错误 Unable to run insert stmt on object
- OracleDBControl启动失败Unable to determine local host from URL REPOSITORY_URL=http://your-url.co 解决方法
- dbstart 报错 Failed to auto-start Oracle Net Listene using /ade/vikrkuma_new/oracle/bin/tnslsnr
- Root-NFS: Unable to get nfsd port number from server, using default
- git clone https://github.com/azkaban/azkaban.git Cloning into 'azkaban'... fatal: unable to access '
- Oracle SELECT INTO 和 INSERT INTO SELECT 两种表复制语句详解
- pip Fatal error in launcher: Unable to create process using '"'
- [oracle] ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener
- Using IP Instances with VLANs or How to Make a Few NICs Look Like Many