MyBatis-Spring-Boot icon indicating copy to clipboard operation
MyBatis-Spring-Boot copied to clipboard

1.1.0 pagehelper-spring-boot-starter 没有分页的查询添加limit

Open wuxusen opened this issue 7 years ago • 6 comments

使用了插件后,会偶尔出现 没有分页的查询 在SQL后自动添加limit,谁遇到类似的情况?

wuxusen avatar Dec 06 '17 08:12 wuxusen

PageHelper.startPage 方法一定要紧跟在查询方法前。

详情看这里:https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/zh/HowToUse.md#3-pagehelper-%E5%AE%89%E5%85%A8%E8%B0%83%E7%94%A8

abel533 avatar Dec 09 '17 07:12 abel533

我们框架适用AOP来实现分页的,代码如下,结果还是没有避免偶然分页是情况 @abel533 ,希望大神能给出解决方案,谢谢 try { if(pageVo!=null && pageVo.getPageNum()!=null){ PageHelper.startPage(Integer.parseInt(pageVo.getPageNum()),Integer.parseInt(pageVo.getPageSize())); result = jp.proceed(args); } finally { PageHelper.clearPage(); }

wuxusen avatar Dec 29 '17 07:12 wuxusen

偶然分页是同一次调用还是不同次?

abel533 avatar Dec 30 '17 08:12 abel533

@abel533 你好 我也在实际环境中遇到了这个问题。在极少数情况下,基本上一个月仅出现了一次。不同线程调用。没有使用pagehelper.startPage的查询在末尾意外的加上了limit。 我测试了在A线程调用pagehelper.startPage后seleep,在B线程进行正常的查找,也没有出现这个错误。当然,根据threadlocal的原因这样是正常的。 所以目前不知道如何排查这个问题。

JKTerrific avatar Sep 05 '18 05:09 JKTerrific

@JKTerrific 注意看这里:https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/zh/HowToUse.md#3-pagehelper-%E5%AE%89%E5%85%A8%E8%B0%83%E7%94%A8

abel533 avatar Sep 06 '18 13:09 abel533

你好检查了代码。它遵循了手册中的规范,但是还是发生了。

JKTerrific avatar Sep 07 '18 11:09 JKTerrific