Browse Source

处理Condition.EMPTY类型强转Wrapper出错的问题,使用Condition.empty()来解决这个问题

Caratacus 7 years ago
parent
commit
b69bf56807

+ 11 - 2
mybatis-plus-support/src/main/java/com/baomidou/mybatisplus/mapper/Condition.java

@@ -31,8 +31,12 @@ public class Condition extends Wrapper {
     /**
      * 构建一个Empty条件构造 避免传递参数使用null
      */
-    public static final Condition EMPTY = Condition.create();
-
+    public static final Wrapper EMPTY = new Wrapper() {
+        @Override
+        public String getSqlSegment() {
+            return null;
+        }
+    };
 
     /**
      * 获取实例
@@ -62,4 +66,9 @@ public class Condition extends Wrapper {
         return isWhere != null ? (isWhere ? sqlWhere : sqlWhere.replaceFirst("WHERE", AND_OR)) : sqlWhere.replaceFirst("WHERE", AND_OR);
 
     }
+
+    public static <T> Wrapper<T> empty() {
+        return (Wrapper<T>) EMPTY;
+    }
+
 }