Sharding-jdbc loop insert Times error

use sharding-jdbc to divide the table, and there is no problem when operating the jpa, used by the database to insert a single piece of data:

for (int i = 1; i < 10; iPP) {
    Sharding sharding = new Sharding();
    sharding.setAppId("1001");
    sharding.setNum(i);

    shardingRepository.save(sharding);
}

the error message is as follows:

javax.persistence.EntityExistsException: A different object with the same identifier value was already associated with the session : [com.zkzong.sj.entity.Sharding-sharp1]

what is the reason for this?

Apr.04,2021

encountered the same problem. Has it been solved?

Menu