shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

sharding jdbc, when insert config useGeneratedKeys , in one Transactional , the ID obtained by batch insertion is the first one

Open fantacy2001 opened this issue 6 years ago • 4 comments

sharding jdbc 4.0.0 mybatis spring sql mapper: insert into stock_move_detail ........ values ..... sharding config : only sharding db , Custom keyGenerator : UidGenerator in one Transactional , Loop in the java code to call single insert Dao(insertByStockMoveDetail),The insertion ID obtained each time in the loop is the first. remove the transaction, it's OK

fantacy2001 avatar Sep 02 '20 09:09 fantacy2001

Hi, do you think your issue is similar to the issues in #6895?

tristaZero avatar Sep 02 '20 10:09 tristaZero

Hi, do you think your issue is similar to the issues in #6895?

It could be similar. BatchInsert under the same transaction #6895 is batchInsert in one sql ,like "insert into table values(),(),();" my question is single insert ,like "insert into table values();" but Loop in the java code to call the sql, the loop is managed by transactions like for(A a : aList){ singleInsert(a); }

fantacy2001 avatar Sep 02 '20 12:09 fantacy2001

It could be similar. BatchInsert under the same transaction

If so, it has been identified as a bug indeed. Please wait for it fixed. I believe the next release will include this bugfix certainly.

Hi, @terrymanu Ping here.

tristaZero avatar Sep 03 '20 06:09 tristaZero

I had the same problem version: 5.1.1
insert into bdf_teacher (teacher_name, class_id) values (#{teacherName}, #{classId})

jiuye9999 avatar Dec 01 '23 09:12 jiuye9999