Pārlūkot izejas kodu

使用transient关键字去除Page中部分字段参与序列化

Caratacus 7 gadi atpakaļ
vecāks
revīzija
47a5217660

+ 1 - 1
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/plugins/pagination/DialectFactory.java

@@ -55,7 +55,7 @@ public class DialectFactory {
     public static String buildPaginationSql(Pagination page, String buildSql, DBType dbType, String dialectClazz)
     public static String buildPaginationSql(Pagination page, String buildSql, DBType dbType, String dialectClazz)
             throws Exception {
             throws Exception {
         // fix #172, 196
         // fix #172, 196
-        return getDialect(dbType, dialectClazz).buildPaginationSql(buildSql, page.getOffsetCurrent(), page.getSize());
+        return getDialect(dbType, dialectClazz).buildPaginationSql(buildSql, page.offsetCurrent(), page.getSize());
     }
     }
 
 
     /**
     /**

+ 1 - 1
mybatis-plus-support/src/main/java/com/baomidou/mybatisplus/plugins/Page.java

@@ -41,7 +41,7 @@ public class Page<T> extends Pagination {
     /**
     /**
      * 查询参数
      * 查询参数
      */
      */
-    private Map<String, Object> condition;
+    private transient Map<String, Object> condition;
 
 
     public Page() {
     public Page() {
         /* 注意,传入翻页参数 */
         /* 注意,传入翻页参数 */

+ 18 - 6
mybatis-plus-support/src/main/java/com/baomidou/mybatisplus/plugins/pagination/Pagination.java

@@ -34,6 +34,18 @@ import com.baomidou.mybatisplus.toolkit.StringUtils;
 public class Pagination extends RowBounds implements Serializable {
 public class Pagination extends RowBounds implements Serializable {
 
 
     private static final long serialVersionUID = 1L;
     private static final long serialVersionUID = 1L;
+    /**
+     * 该操作只是为了忽略RowBounds属性
+     *
+     * @see org.apache.ibatis.session.RowBounds#getOffset()
+     */
+    private transient int offset;
+    /**
+     * 该操作只是为了忽略RowBounds属性
+     *
+     * @see org.apache.ibatis.session.RowBounds#getLimit() ()
+     */
+    private transient int limit;
 
 
     /**
     /**
      * 总数
      * 总数
@@ -43,7 +55,7 @@ public class Pagination extends RowBounds implements Serializable {
     /**
     /**
      * 每页显示条数,默认 10
      * 每页显示条数,默认 10
      */
      */
-    private int size = 10;
+    private transient int size = 10;
 
 
     /**
     /**
      * 总页数
      * 总页数
@@ -58,14 +70,14 @@ public class Pagination extends RowBounds implements Serializable {
     /**
     /**
      * 查询总记录数(默认 true)
      * 查询总记录数(默认 true)
      */
      */
-    private boolean searchCount = true;
+    private transient boolean searchCount = true;
 
 
     /**
     /**
      * 开启排序(默认 true) 只在代码逻辑判断 并不截取sql分析
      * 开启排序(默认 true) 只在代码逻辑判断 并不截取sql分析
      *
      *
      * @see com.baomidou.mybatisplus.mapper.SqlHelper fillWrapper
      * @see com.baomidou.mybatisplus.mapper.SqlHelper fillWrapper
      **/
      **/
-    private boolean openSort = true;
+    private transient boolean openSort = true;
 
 
     /**
     /**
      * <p>
      * <p>
@@ -76,12 +88,12 @@ public class Pagination extends RowBounds implements Serializable {
      * ASC 表示按正序排序(即:从小到大排序)
      * ASC 表示按正序排序(即:从小到大排序)
      * </p>
      * </p>
      */
      */
-    private String orderByField;
+    private transient String orderByField;
 
 
     /**
     /**
      * 是否为升序 ASC( 默认: true )
      * 是否为升序 ASC( 默认: true )
      */
      */
-    private boolean isAsc = true;
+    private transient boolean isAsc = true;
 
 
     public Pagination() {
     public Pagination() {
         super();
         super();
@@ -120,7 +132,7 @@ public class Pagination extends RowBounds implements Serializable {
         return 0;
         return 0;
     }
     }
 
 
-    public int getOffsetCurrent() {
+    public int offsetCurrent() {
         return offsetCurrent(this.current, this.size);
         return offsetCurrent(this.current, this.size);
     }
     }