登录
注册
开源
企业版
高校版
搜索
帮助中心
使用条款
关于我们
开源
企业版
高校版
私有云
模力方舟
AI 队友
登录
注册
代码拉取完成,页面将自动刷新
开源项目
>
数据库相关
>
数据库开发包
&&
Watch
不关注
关注所有动态
仅关注版本发行动态
关注但不提醒动态
740
Star
2.8K
Fork
841
abel533
/
Mybatis_PageHelper
代码
Issues
26
Pull Requests
3
Wiki
统计
流水线
服务
JavaDoc
质量分析
Jenkins for Gitee
腾讯云托管
腾讯云 Serverless
悬镜安全
阿里云 SAE
Codeblitz
SBOM
开发画像分析
我知道了,不再自动展开
更新失败,请稍后重试!
移除标识
内容风险标识
本任务被
标识为内容中包含有代码安全 Bug 、隐私泄露等敏感信息,仓库外成员不可访问
使用RPC时,因Page类引用了RowBounds,导致反序列化失败
已完成
#I7EYZ
韩都衣舍
创建于
2015-09-09 16:50
在使用dubbo时,消费端RPC调用后端服务,消费端并没有任何连接数据库的权限,因此不需要引入mybatis依赖,此时后端返回的集合是分页插件的Page类,这个类引用了RowBounds,导致消费端反序列化Page类时,找不到RowBounds类。 ``` From 2958c17800771fb313cb1acd150d087c11a7a133 Mon Sep 17 00:00:00 2001 From: "Jinkai.Ma" <majinkai@handu.com> Date: Wed, 9 Sep 2015 16:44:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E4=BE=9D=E8=B5=96RowBounds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/github/pagehelper/Page.java | 17 +++++------------ src/main/java/com/github/pagehelper/SqlUtil.java | 6 ++---- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/github/pagehelper/Page.java b/src/main/java/com/github/pagehelper/Page.java index 314b9dc..4c30948 100644 --- a/src/main/java/com/github/pagehelper/Page.java +++ b/src/main/java/com/github/pagehelper/Page.java @@ -24,8 +24,6 @@ package com.github.pagehelper; -import org.apache.ibatis.session.RowBounds; - import java.util.ArrayList; import java.util.List; @@ -105,23 +103,18 @@ public class Page<E> extends ArrayList<E> { setReasonable(reasonable); } - public Page(RowBounds rowBounds, boolean count) { - this(rowBounds, count ? Page.SQL_COUNT : Page.NO_SQL_COUNT); - } - - - public Page(RowBounds rowBounds, int total) { + public Page(int offset, int limit, int total) { super(0); - if (rowBounds.getOffset() == 0 && rowBounds.getLimit() == Integer.MAX_VALUE) { + if (offset == 0 && limit == Integer.MAX_VALUE) { pageSizeZero = true; this.pageSize = 0; } else { - this.pageSize = rowBounds.getLimit(); + this.pageSize = limit; } - this.startRow = rowBounds.getOffset(); + this.startRow = offset; //RowBounds方式默认不求count总数,如果想求count,可以修改这里为SQL_COUNT this.total = total; - this.endRow = this.startRow + rowBounds.getLimit(); + this.endRow = this.startRow + limit; } public List<E> getResult() { diff --git a/src/main/java/com/github/pagehelper/SqlUtil.java b/src/main/java/com/github/pagehelper/SqlUtil.java index 81e3675..241bcdf 100644 --- a/src/main/java/com/github/pagehelper/SqlUtil.java +++ b/src/main/java/com/github/pagehelper/SqlUtil.java @@ -294,10 +294,8 @@ public class SqlUtil implements Constant { if (page == null) { if (params instanceof RowBounds) { RowBounds rowBounds = (RowBounds) params; - if (offsetAsPageNum) { - page = new Page(rowBounds.getOffset(), rowBounds.getLimit(), rowBoundsWithCount); - } else { - page = new Page(rowBounds, rowBoundsWithCount); + page = new Page(rowBounds.getOffset(), rowBounds.getLimit(), rowBoundsWithCount); + if (!offsetAsPageNum) { //offsetAsPageNum=false的时候,由于PageNum问题,不能使用reasonable,这里会强制为false page.setReasonable(false); } -- 2.3.2 (Apple Git-55) ```
在使用dubbo时,消费端RPC调用后端服务,消费端并没有任何连接数据库的权限,因此不需要引入mybatis依赖,此时后端返回的集合是分页插件的Page类,这个类引用了RowBounds,导致消费端反序列化Page类时,找不到RowBounds类。 ``` From 2958c17800771fb313cb1acd150d087c11a7a133 Mon Sep 17 00:00:00 2001 From: "Jinkai.Ma" <majinkai@handu.com> Date: Wed, 9 Sep 2015 16:44:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E4=BE=9D=E8=B5=96RowBounds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/github/pagehelper/Page.java | 17 +++++------------ src/main/java/com/github/pagehelper/SqlUtil.java | 6 ++---- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/github/pagehelper/Page.java b/src/main/java/com/github/pagehelper/Page.java index 314b9dc..4c30948 100644 --- a/src/main/java/com/github/pagehelper/Page.java +++ b/src/main/java/com/github/pagehelper/Page.java @@ -24,8 +24,6 @@ package com.github.pagehelper; -import org.apache.ibatis.session.RowBounds; - import java.util.ArrayList; import java.util.List; @@ -105,23 +103,18 @@ public class Page<E> extends ArrayList<E> { setReasonable(reasonable); } - public Page(RowBounds rowBounds, boolean count) { - this(rowBounds, count ? Page.SQL_COUNT : Page.NO_SQL_COUNT); - } - - - public Page(RowBounds rowBounds, int total) { + public Page(int offset, int limit, int total) { super(0); - if (rowBounds.getOffset() == 0 && rowBounds.getLimit() == Integer.MAX_VALUE) { + if (offset == 0 && limit == Integer.MAX_VALUE) { pageSizeZero = true; this.pageSize = 0; } else { - this.pageSize = rowBounds.getLimit(); + this.pageSize = limit; } - this.startRow = rowBounds.getOffset(); + this.startRow = offset; //RowBounds方式默认不求count总数,如果想求count,可以修改这里为SQL_COUNT this.total = total; - this.endRow = this.startRow + rowBounds.getLimit(); + this.endRow = this.startRow + limit; } public List<E> getResult() { diff --git a/src/main/java/com/github/pagehelper/SqlUtil.java b/src/main/java/com/github/pagehelper/SqlUtil.java index 81e3675..241bcdf 100644 --- a/src/main/java/com/github/pagehelper/SqlUtil.java +++ b/src/main/java/com/github/pagehelper/SqlUtil.java @@ -294,10 +294,8 @@ public class SqlUtil implements Constant { if (page == null) { if (params instanceof RowBounds) { RowBounds rowBounds = (RowBounds) params; - if (offsetAsPageNum) { - page = new Page(rowBounds.getOffset(), rowBounds.getLimit(), rowBoundsWithCount); - } else { - page = new Page(rowBounds, rowBoundsWithCount); + page = new Page(rowBounds.getOffset(), rowBounds.getLimit(), rowBoundsWithCount); + if (!offsetAsPageNum) { //offsetAsPageNum=false的时候,由于PageNum问题,不能使用reasonable,这里会强制为false page.setReasonable(false); } -- 2.3.2 (Apple Git-55) ```
评论 (
8
)
登录
后才可以发表评论
状态
已完成
待办的
进行中
已完成
已关闭
负责人
未设置
标签
未设置
标签管理
里程碑
未关联里程碑
未关联里程碑
Pull Requests
未关联
未关联
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
未关联
分支 (
-
)
标签 (
-
)
开始日期   -   截止日期
-
置顶选项
不置顶
置顶等级:高
置顶等级:中
置顶等级:低
优先级
不指定
严重
主要
次要
不重要
参与者(4)
Java
1
https://gitee.com/free/Mybatis_PageHelper.git
git@gitee.com:free/Mybatis_PageHelper.git
free
Mybatis_PageHelper
Mybatis_PageHelper
点此查找更多帮助
搜索帮助
Git 命令在线学习
如何在 Gitee 导入 GitHub 仓库
Git 仓库基础操作
企业版和社区版功能对比
SSH 公钥设置
如何处理代码冲突
仓库体积过大,如何减小?
如何找回被删除的仓库数据
Gitee 产品配额说明
GitHub仓库快速导入Gitee及同步更新
什么是 Release(发行版)
将 PHP 项目自动发布到 packagist.org
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册