From 491e4a6ed36eca8e7a19ed19a4954041608823ca Mon Sep 17 00:00:00 2001 From: wangdehai Date: Tue, 6 Aug 2024 11:02:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=93=E5=8D=B0=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E7=BB=86=E8=85=BB=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../sqlprinter/starter/interceptor/SqlPrinter.java | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 0d1fb35..ca520fd 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ - 2.3.18-RELEASE + 2.3.19-RELEASE https://maven.aliyun.com/repository/public diff --git a/sqlprinter-spring-boot-starter/src/main/java/com/github/dreamroute/sqlprinter/starter/interceptor/SqlPrinter.java b/sqlprinter-spring-boot-starter/src/main/java/com/github/dreamroute/sqlprinter/starter/interceptor/SqlPrinter.java index 77cbd64..7aadb59 100644 --- a/sqlprinter-spring-boot-starter/src/main/java/com/github/dreamroute/sqlprinter/starter/interceptor/SqlPrinter.java +++ b/sqlprinter-spring-boot-starter/src/main/java/com/github/dreamroute/sqlprinter/starter/interceptor/SqlPrinter.java @@ -103,7 +103,7 @@ public Object intercept(Invocation invocation) throws Exception { try { Object target = invocation.getTarget(); Parse p = new Parse(); - // 非查询走这里(非查询不走ResultSetHandler接口,所以放在这里) + // 非查询走这里(非查询不走ResultSetHandler接口,所以放在这里, 直接打印sql) if (target instanceof ParameterHandler) { MetaObject m = config.newMetaObject(target); MappedStatement ms = (MappedStatement) m.getValue("mappedStatement"); @@ -112,9 +112,13 @@ public Object intercept(Invocation invocation) throws Exception { p.id = ms.getId(); processSql(ms.getId(), ms.getBoundSql(m.getValue("parameterObject")), p); } + // 对于((PreparedStatement) countStmt).execute()这种方式执行的sql, 不会走ResultSetHandler拦截, 所以不会走下方的查询逻辑, 因此打印sql放在这里, 而分页插件就包含((PreparedStatement) countStmt).execute()这种查询 + else if(ms.getId().contains("分页统计")) { + p = getSql(invocation); + } } - // 查询走这里 + // 查询走这里, 这里会生成sql else { p = getSql(invocation); }