rename Db.updateBatchEntity to Db.updateEntitiesBatch

This commit is contained in:
开源海哥 2023-05-19 18:23:57 +08:00
parent 11959d1196
commit afac7c4982
3 changed files with 6 additions and 6 deletions

View File

@ -69,10 +69,10 @@ Db.updateBatch(sql, new BatchArgsSetter() {
虽然这个方法叫 `updateBatch`,但一样可以执行 `insert``update` 等任何 SQL 这个方法类似 Spring 的 `jdbcTemplate.batchUpdate()` 方法。
## `Db.updateBatchEntity` 方法
## `Db.updateEntitiesBatch` 方法
这个方法用于批量根据 id 更新 entity其是对 `Db.executeBatch` 的封装,使用代码如下:
```java
List<Account> accounts = ....
Db.updateBatchEntity(accounts, 1000);
Db.updateEntitiesBatch(accounts, 1000);
```

View File

@ -278,7 +278,7 @@ public class Db {
* @param batchSize 批次大小
* @return int
*/
public static <T> int updateBatchEntity(Collection<T> entities, int batchSize) {
public static <T> int updateEntitiesBatch(Collection<T> entities, int batchSize) {
List<T> list = CollectionUtil.toList(entities);
return Arrays.stream(executeBatch(list.size(), batchSize, RowMapper.class, (mapper, index) -> {
T entity = list.get(index);
@ -292,8 +292,8 @@ public class Db {
* @param entities 实体
* @return int 影响行数
*/
public static <T> int updateBatchEntity(Collection<T> entities) {
return updateBatchEntity(entities, RowMapper.DEFAULT_BATCH_SIZE);
public static <T> int updateEntitiesBatch(Collection<T> entities) {
return updateEntitiesBatch(entities, RowMapper.DEFAULT_BATCH_SIZE);
}

View File

@ -197,7 +197,7 @@ public interface RowMapper {
* 更新 entity主要用于进行批量更新的场景
* @param entity 实体类
* @see RowSqlProvider#updateEntity(Map)
* @see Db#updateBatchEntity(Collection, int)
* @see Db#updateEntitiesBatch(Collection, int)
*/
@UpdateProvider(value = RowSqlProvider.class, method = "updateEntity")
int updateEntity(@Param(FlexConsts.ENTITY) Object entity);