fix:修复编译器无法正确匹配updateBatch重载方法的问题

This commit is contained in:
Wudadada 2024-08-21 12:38:54 +08:00
parent cb6b0fb1d4
commit 1951037da7
2 changed files with 5 additions and 5 deletions

View File

@ -64,9 +64,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account>
- **update(entity, query)**:根据 `QueryWrapper` 构建的条件更新数据,实体类可以没有主键(如果有也会被忽略),实体类的 null 属性,会自动被忽略。 - **update(entity, query)**:根据 `QueryWrapper` 构建的条件更新数据,实体类可以没有主键(如果有也会被忽略),实体类的 null 属性,会自动被忽略。
- **update(entity, condition)**:根据 `QueryCondition` 构建的条件更新数据,实体类可以没有主键(如果有也会被忽略),实体类的 null 属性,会自动被忽略。 - **update(entity, condition)**:根据 `QueryCondition` 构建的条件更新数据,实体类可以没有主键(如果有也会被忽略),实体类的 null 属性,会自动被忽略。
- **updateBatch(entities)**:批量保存多条数据,要求主键值不能为空,否则会抛出异常;同时,数据为 null 的字段不会更新到数据库。 - **updateBatch(entities)**:批量保存多条数据,要求主键值不能为空,否则会抛出异常;同时,数据为 null 的字段不会更新到数据库。
- **updateBatch(entities, ignoreNulls)**:批量保存多条数据,要求主键值不能为空,否则会抛出异常;可以选择数据为 null 的字段是否更新到数据库。 - **updateBatchWithIgnoreNulls(entities, ignoreNulls)**:批量保存多条数据,要求主键值不能为空,否则会抛出异常;可以选择数据为 null 的字段是否更新到数据库。
- **updateBatch(entities, size)**:批量保存多条数据,按指定数量切分,要求主键值不能为空,否则会抛出异常;同时,数据为 null 的字段不会更新到数据库。 - **updateBatch(entities, size)**:批量保存多条数据,按指定数量切分,要求主键值不能为空,否则会抛出异常;同时,数据为 null 的字段不会更新到数据库。
- **updateBatch(entities, size, ignoreNulls)**:批量保存多条数据,按指定数量切分,要求主键值不能为空,否则会抛出异常;可以选择数据为 null 的字段是否更新到数据库。 - **updateBatchWithIgnoreNulls(entities, size, ignoreNulls)**:批量保存多条数据,按指定数量切分,要求主键值不能为空,否则会抛出异常;可以选择数据为 null 的字段是否更新到数据库。
## 查询数据 ## 查询数据

View File

@ -279,8 +279,8 @@ public interface IService<T> {
* @return boolean {@code true} 更新成功{@code false} 更新失败 * @return boolean {@code true} 更新成功{@code false} 更新失败
* @apiNote {@code ignoreNulls} {@code true}实体类中为 {@code null} 的属性不会更新到数据库 * @apiNote {@code ignoreNulls} {@code true}实体类中为 {@code null} 的属性不会更新到数据库
*/ */
default boolean updateBatch(Collection<T> entities, Boolean ignoreNulls) { default boolean updateBatchWithIgnoreNulls(Collection<T> entities, boolean ignoreNulls) {
return updateBatch(entities, DEFAULT_BATCH_SIZE, ignoreNulls); return updateBatchWithIgnoreNulls(entities, DEFAULT_BATCH_SIZE, ignoreNulls);
} }
/** /**
@ -307,7 +307,7 @@ public interface IService<T> {
* @return {@code true} 更新成功{@code false} 更新失败 * @return {@code true} 更新成功{@code false} 更新失败
* @apiNote {@code ignoreNulls} {@code true}实体类中为 {@code null} 的属性不会更新到数据库 * @apiNote {@code ignoreNulls} {@code true}实体类中为 {@code null} 的属性不会更新到数据库
*/ */
default boolean updateBatch(Collection<T> entities, int batchSize, boolean ignoreNulls) { default boolean updateBatchWithIgnoreNulls(Collection<T> entities, int batchSize, boolean ignoreNulls) {
Class<BaseMapper<T>> usefulClass = (Class<BaseMapper<T>>) ClassUtil.getUsefulClass(getMapper().getClass()); Class<BaseMapper<T>> usefulClass = (Class<BaseMapper<T>>) ClassUtil.getUsefulClass(getMapper().getClass());
return SqlUtil.toBool(Db.executeBatch(entities, batchSize, usefulClass, (mapper, entity) -> mapper.update(entity, ignoreNulls))); return SqlUtil.toBool(Db.executeBatch(entities, batchSize, usefulClass, (mapper, entity) -> mapper.update(entity, ignoreNulls)));
} }