Mybatis batch insert problem
Incorrect wording:
INSERT INTO t_csm_customer_product(id, customer_code, product_code) values
<foreach collection="lists" close=")" open="(" index="i" item="cstProduct" separator=",">
#{cstProduct.id},
#{cstProduct.customerCode},
#{cstProduct.productCode}
</foreach>
Error Messages: Error updating database…Cause: java.sql.SQLException: Column count doesn’t match value count at row 1
Print sql:
INSERT INTO table(id, name, value) values ( ?,?,?,?,?,?)
The whole bracket is enclosed
The SQL we want:
INSERT INTO table(id, name, value) values ( ?,?,?),(?,?,?)
Adjust XML to:
INSERT INTO t_csm_customer_product(id, customer_code, product_code) values
<foreach collection="lists" index="i" item="cstProduct" separator=",">
(#{cstProduct.id},
#{cstProduct.customerCode},
#{cstProduct.productCode})
</foreach>
Missing parameter () in key foreach
Similar Posts:
- mysql Column count doesn’t match value count at row 1
- How to Use awk to Analyze Nginx Log
- MySQL Executenamy: How to Write a batch of data
- AttributeError: ‘tuple’ object has no attribute ‘extend’
- How to solve the problem of potentially unsupported type in Python sqllite
- [Solved] Vue error: (Avoid using non-primitive value as key, use stringnumber value instead.)
- How to Solve Error: Cannot read property ‘map’ of undefined
- [Solved] pymongo.errors.OperationFailure: Authentication failed.
- Oracle ORA-00936: missing expression [How to Solve]