jeff-lai opened a new issue, #23775:
URL: https://github.com/apache/shardingsphere/issues/23775
## Question
can support batchSave method returns the PK primary in
shardingsphere-jdbc-core v5.3.1 with mybatis-plus-boot-starter?
## dependencies ##
```
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core</artifactId>
<version>5.3.1</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
<version>8.0.32</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.2</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.33</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
```
## yaml ##
```
rules:
- !READWRITE_SPLITTING
dataSources:
readwrite_ds:
staticStrategy:
writeDataSourceName: write_ds
readDataSourceNames:
- read_ds_0
- read_ds_1
loadBalancerName: random
loadBalancers:
random:
type: RANDOM
```
## entity ##
```
@TableName("person")
@Data
public class Person {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private String name;
private Integer age;
}
```
## service ##
```
public interface PersonService extends IService<Person> {
}
@Service("personService")
public class PersonServiceImpl extends ServiceImpl<PersonDao, Person>
implements PersonService {
}
```
## test ##
```
@Resource
private PersonService personService;
@Test
void testSaveOne() {
Person person = new Person();
person.setName("xxx");
person.setAge(12);
this.personService.save(person);
Assertions.assertNotNull(person.getId());// true
}
@Test
void testSaveBatch() {
List<Person> personList = new ArrayList<>();
for (int i = 0; i < 10; i++) {
Person person = new Person();
person.setName("xxx" + 1);
person.setAge(i + 1);
personList.add(person);
}
this.personService.saveBatch(personList);
Assertions.assertNotNull(personList.get(0).getId());// false
}
```
--
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]