sharding jdbc, when insert config useGeneratedKeys , in one Transactional , the ID obtained by batch insertion is the first one! How to solve this problem
Question
For English only, other languages will not accept.
Before asking a question, make sure you have:
- Googled your question.
- Searched open and closed GitHub issues.
- Read documentation: ShardingSphere Doc.
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.
mysql sql: bdf_teacher (teacher_name, class_id)
values (#{teacherName}, #{classId})
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
mysql sql: insert into
bdf_teacher(teacher_name,class_id) values (#{teacherName}, #{classId})
I encountered the same issue in sharding-jdbc 4.1.1. Based on my analysis, it was because in org.apache.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement#prepare, only the lastId was retrieved. I'm not sure about the rationale behind this design. However, when I upgraded to sharding-jdbc 5, this issue was fixed. The relevant method involved is org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement#createExecutionContext.
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
The version 4.1.1 is out of service, please try version 5.5.x
you may write issues of version 4.1.1 here :https://gitee.com/shardcn/shardingsphere_4.1.1