From ff134913890e09a21056e5ffcf3a9c7e50c4b812 Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Fri, 25 Aug 2023 14:53:49 +0800 Subject: [PATCH 1/7] =?UTF-8?q?remove:=20=E7=A7=BB=E9=99=A4=E6=AE=8B?= =?UTF-8?q?=E7=BC=BA=E6=94=AF=E6=8C=81=E7=9A=84=E4=BB=A3=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mybatisflex/core/row/DbChain.java | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/DbChain.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/DbChain.java index 4f6d3feb..05a6e4e6 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/DbChain.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/DbChain.java @@ -41,12 +41,9 @@ import java.util.stream.Collectors; public class DbChain extends QueryWrapperAdapter implements PropertySetter { private String schema; - private String tableName; + private final String tableName; private Row rowData; - private DbChain() { - } - private DbChain(String tableName) { this.tableName = tableName; } @@ -56,22 +53,12 @@ public class DbChain extends QueryWrapperAdapter implements PropertySet this.tableName = tableName; } - /** - * 覆盖 {@link QueryWrapper} 的静态方法,仅用于查询,必须使用 {@code from(...)} 方法指定表。 - * - * @deprecated 使用 {@code table(...)} 方法创建 - */ - @Deprecated public static DbChain create() { - return new DbChain(); + throw new UnsupportedOperationException("please use DbChain#table(...)"); } - /** - * @deprecated 覆盖 {@link QueryWrapper} 的静态方法 - */ - @Deprecated public static DbChain create(Object entity) { - throw new UnsupportedOperationException(); + throw new UnsupportedOperationException("please use DbChain#table(...)"); } public static DbChain table(String tableName) { From 24ab62e6159ccc9542f81f9ade4ca80b2687d31a Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Fri, 25 Aug 2023 14:54:10 +0800 Subject: [PATCH 2/7] =?UTF-8?q?remove:=20=E7=A7=BB=E9=99=A4=E8=A1=8C?= =?UTF-8?q?=E4=B8=BA=E4=B8=8D=E4=B8=80=E8=87=B4=E7=9A=84=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatisflex/core/service/IService.java | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/service/IService.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/service/IService.java index 64db3362..816a5820 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/service/IService.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/service/IService.java @@ -93,34 +93,6 @@ public interface IService { return SqlUtil.toBool(Db.executeBatch(entities, batchSize, usefulClass, BaseMapper::insertSelective)); } - /** - *

批量保存实体类对象数据。 - * - * @param entities 实体类对象 - * @return {@code true} 保存成功,{@code false} 保存失败。 - * @deprecated 为保持 Service 层 API 一致性,默认方法都是忽略实体类 {@code null} 属性的数据。 - * 另外,该方法将在 1.6.0 版本被移除。 - */ - @Deprecated - default boolean saveBatchSelective(Collection entities) { - return saveBatchSelective(entities, DEFAULT_BATCH_SIZE); - } - - /** - *

批量保存实体类对象数据。 - * - * @param entities 实体类对象 - * @param batchSize 每次保存切分的数量 - * @return {@code true} 保存成功,{@code false} 保存失败。 - * @deprecated 为保持 Service 层 API 一致性,默认方法都是忽略实体类 {@code null} 属性的数据。 - * 另外,该方法将在 1.6.0 版本被移除。 - */ - @Deprecated - default boolean saveBatchSelective(Collection entities, int batchSize) { - Class> usefulClass = (Class>) ClassUtil.getUsefulClass(getMapper().getClass()); - return SqlUtil.toBool(Db.executeBatch(entities, batchSize, usefulClass, BaseMapper::insertSelective)); - } - /** *

保存或者更新实体类对象数据。 * From c7089b55b388ecf694e994540aadf652a3f4b3d2 Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Fri, 25 Aug 2023 14:54:37 +0800 Subject: [PATCH 3/7] =?UTF-8?q?remove:=20=E7=A7=BB=E9=99=A4=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E5=87=BA=E7=8E=B0=E6=B3=9B=E5=9E=8B=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/query/QueryCondition.java | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryCondition.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryCondition.java index 375bc85a..a273bc51 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryCondition.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryCondition.java @@ -27,7 +27,6 @@ import com.mybatisflex.core.util.StringUtil; import java.lang.reflect.Array; import java.util.List; import java.util.function.BooleanSupplier; -import java.util.function.Predicate; public class QueryCondition implements CloneSupport { @@ -126,38 +125,6 @@ public class QueryCondition implements CloneSupport { return this; } - /** - *

动态条件构造。 - * - *

推荐将 {@link Predicate} 推断写在填写的值的后面,以确保泛型对应,例如: - *

{@code
-     * ACCOUNT.ID.in(idList, CollectionUtil::isNotEmpty);
-     * }
- * - * @see #when(boolean) - * @see #when(BooleanSupplier) - * @deprecated 由于 {@link QueryCondition} 中属性 {@link #value} 的类型为 Object - * 类型,没有使用泛型,所以该方法泛型推断可能会出现问题。 - */ - @Deprecated - @SuppressWarnings("unchecked") - public QueryCondition when(Predicate fn) { - Object val = this.value; - if ((SqlConsts.LIKE.equals(logic) || SqlConsts.NOT_LIKE.equals(logic)) - && val instanceof String) { - String valStr = (String) val; - if (valStr.startsWith(SqlConsts.PERCENT_SIGN)) { - valStr = valStr.substring(1); - } - if (valStr.endsWith(SqlConsts.PERCENT_SIGN)) { - valStr = valStr.substring(0, valStr.length() - 1); - } - val = valStr; - } - this.effective = fn.test((T) val); - return this; - } - public boolean checkEffective() { return effective; } From a68cdd1bf6750713b5a25953e1725b6eca29e6e0 Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Fri, 25 Aug 2023 14:54:59 +0800 Subject: [PATCH 4/7] =?UTF-8?q?remove:=20=E7=A7=BB=E9=99=A4=E9=9D=9E?= =?UTF-8?q?=E9=93=BE=E5=BC=8F=E5=85=B3=E8=81=94=E6=9E=84=E5=BB=BA=E7=9A=84?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatisflex/core/query/QueryChain.java | 68 ------------------- 1 file changed, 68 deletions(-) diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryChain.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryChain.java index bef5ab07..719b5158 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryChain.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryChain.java @@ -18,13 +18,9 @@ package com.mybatisflex.core.query; import com.mybatisflex.core.BaseMapper; import com.mybatisflex.core.mybatis.Mappers; -import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.table.TableInfo; import com.mybatisflex.core.table.TableInfoFactory; -import java.util.List; -import java.util.Optional; - /** * {@link QueryWrapper} 链式调用。 * @@ -58,70 +54,6 @@ public class QueryChain extends QueryWrapperAdapter> implements return this; } - /** - * @deprecated 该方法将在 1.6.0 版本移除 - */ - @Deprecated - public T oneWithRelations() { - return baseMapper.selectOneWithRelationsByQuery(this); - } - - /** - * @deprecated 该方法将在 1.6.0 版本移除 - */ - @Deprecated - public R oneWithRelationsAs(Class asType) { - return baseMapper.selectOneWithRelationsByQueryAs(this, asType); - } - - /** - * @deprecated 该方法将在 1.6.0 版本移除 - */ - @Deprecated - public Optional oneWithRelationsOpt() { - return Optional.ofNullable(baseMapper.selectOneWithRelationsByQuery(this)); - } - - /** - * @deprecated 该方法将在 1.6.0 版本移除 - */ - @Deprecated - public Optional oneWithRelationsAsOpt(Class asType) { - return Optional.ofNullable(baseMapper.selectOneWithRelationsByQueryAs(this, asType)); - } - - /** - * @deprecated 该方法将在 1.6.0 版本移除 - */ - @Deprecated - public List listWithRelations() { - return baseMapper.selectListWithRelationsByQuery(this); - } - - /** - * @deprecated 该方法将在 1.6.0 版本移除 - */ - @Deprecated - public List listWithRelationsAs(Class asType) { - return baseMapper.selectListWithRelationsByQueryAs(this, asType); - } - - /** - * @deprecated 该方法将在 1.6.0 版本移除 - */ - @Deprecated - public Page pageWithRelations(Page page) { - return baseMapper.paginateWithRelations(page, this); - } - - /** - * @deprecated 该方法将在 1.6.0 版本移除 - */ - @Deprecated - public Page pageWithRelationsAs(Page page, Class asType) { - return baseMapper.paginateWithRelationsAs(page, this, asType); - } - @Override public String toSQL() { TableInfo tableInfo = TableInfoFactory.ofMapperClass(baseMapper.getClass()); From 3f637dfe3c814bf51ed4711389e12ac9b82c87a8 Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Fri, 25 Aug 2023 14:57:41 +0800 Subject: [PATCH 5/7] =?UTF-8?q?remove:=20=E7=A7=BB=E9=99=A4=E9=9D=9E?= =?UTF-8?q?=E6=B3=9B=E5=9E=8B=E7=9A=84=E4=BB=A3=E7=A0=81=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9B=BF=E4=BB=A3=E6=96=B9=E6=B3=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mybatisflex/core/query/If.java | 67 ++++++------------- 1 file changed, 22 insertions(+), 45 deletions(-) diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/If.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/If.java index 7772f2b7..f0a210b6 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/If.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/If.java @@ -15,10 +15,8 @@ */ package com.mybatisflex.core.query; -import com.mybatisflex.core.util.ClassUtil; import com.mybatisflex.core.util.StringUtil; -import java.lang.reflect.Array; import java.util.Collection; import java.util.Map; @@ -38,59 +36,38 @@ public class If { * 判断对象是否非空 */ public static boolean notNull(Object object) { - return !isNull(object); + return object != null; } - /** - * 查看某个对象是否为空,支持数组、集合、map 等 - * - * @param object - * @deprecated 无泛型,多 instanceof 判断 - */ - @Deprecated - public static boolean notEmpty(Object object) { - if (object == null) { - return false; - } - - if (object instanceof Collection) { - return !((Collection) object).isEmpty(); - } - - if (ClassUtil.isArray(object.getClass())) { - return Array.getLength(object) > 0; - } - - if (object instanceof Map) { - return !((Map) object).isEmpty(); - } - - if (object instanceof String) { - return StringUtil.isNotBlank((String) object); - } - return true; + public static boolean isEmpty(T[] array) { + return array != null && array.length == 0; } - - /** - * 查看某个对象是否为空数据 或者 null - * - * @param object - * @deprecated 无泛型,多 instanceof 判断 - */ - @Deprecated - public static boolean isEmpty(Object object) { - return !notEmpty(object); + public static boolean isNotEmpty(T[] array) { + return !isEmpty(array); } + public static boolean isEmpty(Map map) { + return map != null && map.isEmpty(); + } + + public static boolean isNotEmpty(Map map) { + return !isEmpty(map); + } + + public static boolean isEmpty(Collection collection) { + return collection != null && collection.isEmpty(); + } + + public static boolean isNotEmpty(Collection collection) { + return !isEmpty(collection); + } /** * 查看某个 string 对象是否有文本内容 - * - * @param object */ - public static boolean hasText(Object object) { - return object != null && StringUtil.isNotBlank((String) object); + public static boolean hasText(String string) { + return StringUtil.isNotBlank(string); } } From 52985ab9a6752feeeaf262854ddde546edf5e64d Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Fri, 25 Aug 2023 14:58:11 +0800 Subject: [PATCH 6/7] =?UTF-8?q?fix:=20=E5=A4=84=E7=90=86=E6=94=B9=E5=8A=A8?= =?UTF-8?q?=E5=B8=A6=E6=9D=A5=E7=9A=84=E5=BD=B1=E5=93=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/mybatisflex/test/EntityTestStarter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/EntityTestStarter.java b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/EntityTestStarter.java index 79e2dec8..4afa97a8 100644 --- a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/EntityTestStarter.java +++ b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/EntityTestStarter.java @@ -134,13 +134,13 @@ public class EntityTestStarter { .from(Article.class) // .leftJoin(Account.class).as("a").on(ARTICLE.ACCOUNT_ID.eq(ACCOUNT.ID)) .leftJoin(Account.class).as("a").on(wrapper -> wrapper.where(Account::getId).eq(Article::getAccountId)) - .where(Account::getId).ge(100, If::notEmpty) + .where(Account::getId).ge(100, If::notNull) .and(wrapper -> { wrapper.where(Account::getId).ge(100) .or(Account::getAge).gt(200) .and(Article::getAccountId).eq(200) .or(wrapper1 -> { - wrapper1.where(Account::getId).like("a", If::notEmpty); + wrapper1.where(Account::getId).like("a", If::hasText); }) ; }); From 2d8086cb7ce2f0c7e13ba8acfe1b3ec9f946934a Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Fri, 25 Aug 2023 14:58:35 +0800 Subject: [PATCH 7/7] =?UTF-8?q?test:=20=E6=B5=8B=E8=AF=95=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E6=9D=A1=E4=BB=B6=E6=9E=84=E5=BB=BA=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mybatisflex/coretest/DynamicConditionTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mybatis-flex-core/src/test/java/com/mybatisflex/coretest/DynamicConditionTest.java b/mybatis-flex-core/src/test/java/com/mybatisflex/coretest/DynamicConditionTest.java index f52b10bd..4abfd151 100644 --- a/mybatis-flex-core/src/test/java/com/mybatisflex/coretest/DynamicConditionTest.java +++ b/mybatis-flex-core/src/test/java/com/mybatisflex/coretest/DynamicConditionTest.java @@ -17,7 +17,6 @@ package com.mybatisflex.coretest; import com.mybatisflex.core.query.*; -import com.mybatisflex.core.util.CollectionUtil; import com.mybatisflex.core.util.StringUtil; import org.junit.Test; @@ -52,7 +51,7 @@ public class DynamicConditionTest { String sql = QueryWrapper.create() .from(ACCOUNT) .where(ACCOUNT.ID.in(idList).when(false)) - .where(ACCOUNT.ID.in(idList, CollectionUtil::isNotEmpty)) + .where(ACCOUNT.ID.in(idList, If::isNotEmpty)) .where(ACCOUNT.ID.in(idList).when(idList::isEmpty)) .toSQL();