wqzcoder opened a new issue, #27541:
URL: https://github.com/apache/shardingsphere/issues/27541
## Question
**For English only**, other languages will not accept.
The version of Shardingspher-jdbc-core I'm using is 5.1.1. I integrated
MybatisPlus to perform batch updates as follows:
<update id="updateByIdsAndCompanyIdBatch" parameterType="java.util.List">
<foreach collection="poList" item="item" separator=";">
update operation_plan_target set tartget_key = #{item.targetKey},
target_type = #{item.targetType},
target_value = #{item.targetValue}, target_detail = #{item.targetDetail}
where id = #{[item.id](http://item.id/)}
and company_id = #{companyId}
</foreach>
</update>
I split tables based on the company_id field, but when using this batch
update, the resulting SQL statements look like this:
update operation_plan_target_27 set tartget_key = 1, target_type = 1,
target_value = 1, target_detail = 2 where id = 1 and company_id =
901117781768839168;
update operation_plan_target set tartget_key = 2, target_type = 2,
target_value = 2, target_detail = 2 where id = 2 and company_id =
901117781768839168.
However, when I choose to update them one by one, each table will be
correctly sharded. Here is an example:
ShardingSphere-SQL Actual SQL: db0 ::: UPDATE operation_plan_target_27 SET
company_id=?, target_key=?, target_value=?, last_uid=? WHERE is_deleted=0 AND
(id = ? AND company_id = ?)
::: [901117781768839168, sale, 48.38, 129080, 139338548000636928,
901117781768839168] <== Updates: 1
ShardingSphere-SQL Actual SQL: db0 ::: UPDATE operation_plan_target_27 SET
company_id=?, target_key=?, target_value=?, last_uid=? WHERE is_deleted=0 AND
(id = ? AND company_id = ?)
::: [901117781768839168, estimatedGrossProfitRate, 38.38, 129080,
139338548000636929, 901117781768839168] <== Updates: 1.
Do you have a corresponding SPI interface to handle the failure of batch
updates like this? It would be helpful for us developers to rewrite and inject,
or do you have other suggestions?
As you can see, only the first SQL statement split the table based on the
companyid, while the subsequent ones did not.
Before asking a question, make sure you have:
This is a result that has been updated one by one after correcting the
distribution table.

- Googled your question.
- Searched open and closed [GitHub
issues](https://github.com/apache/shardingsphere/issues).
- Read documentation: [ShardingSphere
Doc](https://shardingsphere.apache.org/document/current/en/overview).
Please pay attention on issues you submitted, because we maybe need more
details.
If no response anymore and we cannot reproduce it on current information, we
will **close it**.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail:
[email protected]
For queries about this service, please contact Infrastructure at:
[email protected]