Closed yunmengmeng closed 2 months ago
now i use useGeneratedKeys="true" keyProperty="xxx"
to replace SELECT LAST_INSERT_ID()
Hi @yunmengmeng, thank you for your feedback. If you are using sharding feature, then I recommend using distributed id instead of mysql incrementing id.
你好@yunmengmeng, 感谢您的反馈意见。如果您使用分片功能,那么我建议使用分布式 id 而不是 mysql 递增 id。
我配置了分布式id,数据能够正常insert进数据库,并且数据库中有雪花算法生成的id,但当我想从内存中获取id时很像发现没有回写id,我想知道支持主键回写吗?
The sharding is improved in each version, can you test the latest version?
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
I set two databases.The second is sharding database. When i use
INSERT INTO .... SELECT LAST_INSERT_ID() AS ...
to the first dabase,the tables's primary key type is auto-incrment,it saves in the first database,but when querying insert id,it's return value is wrong.Just retuns 0.Which version of ShardingSphere did you use?
5.1.2
Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
Expected behavior
LAST_INSERT_ID()
Actual behavior
0
Reason analyze (If you can)
It chooses the second database.
PartialSQLRouteExecutor
Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
INSERT INTO tree1 (pid) VALUES (1); SELECT LAST_INSERT_ID() AS id;