pagehelper-spring-boot icon indicating copy to clipboard operation
pagehelper-spring-boot copied to clipboard

分页返回总记录数(total)有问题

Open duxiaolong opened this issue 7 years ago • 4 comments

版本信息:

Spring-Boot:1.5.8.RELEASE
mybatis-spring-boot-starter:1.3.1
pagehelper-spring-boot-starter:1.2.3

配置信息如下:

  1. pagehelper.helperDialect=oracle 有分页,但是,总数(total)不对,显示的是pageSize的大小

  2. pagehelper.helperDialect=com.github.pagehelper.dialect.helper.OracleDialect 有分页,但是,总数(total)不对,显示的是pageSize的大小

  3. pagehelper.Dialect=com.github.pagehelper.dialect.helper.OracleDialect 没有分页,查询的是全部数据,但是总数(total)是对的

  4. pagehelper.Dialect=oracle 报错: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration': Invocation of init method failed; nested exception is com.github.pagehelper.PageException: java.lang.ClassNotFoundException: oracle

duxiaolong avatar Jan 13 '18 03:01 duxiaolong

pagehelper.helperDialect=oracle 这个是对的。

第二个配置也对。

你用PageInfo了吗?你比较的total和pageSize是基于Page还是PageInfo?

在PageInfo中,如果构造参数传入的不是Page类型,就会当成List,然后total=list.size()

所以你需要通过日志判断,你的查询是否真正经过了count和分页查询。

abel533 avatar Jan 13 '18 14:01 abel533

出问题的兄弟 你是不是用了dubbo这种分布式的东西了

hanzhenchaoGit avatar Mar 15 '18 06:03 hanzhenchaoGit

兄弟 , 是不 把 pagehelper.default-count=true 设置成 false 了。 设置成false 就变成-1 了。

haochencheng avatar Dec 03 '18 09:12 haochencheng

还有一种情况, 就是 java代码里用了pagehelper, 但是xml里没有配置插件

coderSnail avatar Jan 13 '21 10:01 coderSnail