mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-07 17:18:24 +08:00
rename Db.updateBatchEntity to Db.updateEntitiesBatch
This commit is contained in:
parent
11959d1196
commit
afac7c4982
@ -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);
|
||||
```
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user