Skip to content

Commit 0cf4be6

Browse files
committed
优化count 分页问题
1 parent 2a663cc commit 0cf4be6

File tree

1 file changed

+8
-2
lines changed
  • hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/plgins/pager

1 file changed

+8
-2
lines changed

hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/plgins/pager/PagerInterceptor.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,14 @@ public Object plugin(Object target) {
4949
MetaObject metaStatementHandler = SystemMetaObject.forObject(statementHandler);
5050
String sql = statementHandler.getBoundSql().getSql();
5151
Pager pager = Pager.getAndReset();
52-
String newSql = sql;
53-
if (sql.trim().toLowerCase().startsWith("select")) {
52+
53+
String lower = sql.trim();
54+
55+
if (lower.startsWith("select")) {
56+
if (lower.contains("count(")) {
57+
return Plugin.wrap(target, this);
58+
}
59+
String newSql = sql;
5460
if (pager != null) {
5561
newSql = EasyOrmSqlBuilder.getInstance()
5662
.getActiveDatabase().getDialect()

0 commit comments

Comments
 (0)