From 51ed3071916ef67def57f819ed92208a8ac31f97 Mon Sep 17 00:00:00 2001 From: yefeng <1226325909@qq.com> Date: Mon, 2 Sep 2024 21:35:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9C=A8=E5=A4=8D=E5=88=B6countBoundSql?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E5=A4=8D=E5=88=B6additiona?= =?UTF-8?q?lParameter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/github/pagehelper/PageInterceptor.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/github/pagehelper/PageInterceptor.java b/src/main/java/com/github/pagehelper/PageInterceptor.java index 2f645801..0b03e787 100644 --- a/src/main/java/com/github/pagehelper/PageInterceptor.java +++ b/src/main/java/com/github/pagehelper/PageInterceptor.java @@ -51,6 +51,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Properties; import java.util.concurrent.Future; @@ -183,6 +184,12 @@ private Future asyncCount(MappedStatement ms, BoundSql boundSql, Object pa Configuration configuration = ms.getConfiguration(); //异步不能复用 BoundSql,因为分页使用时会添加分页参数,这里需要复制一个新的 BoundSql countBoundSql = new BoundSql(configuration, boundSql.getSql(), new ArrayList<>(boundSql.getParameterMappings()), parameter); + Map additionalParameter = ExecutorUtil.getAdditionalParameter(boundSql); + if (additionalParameter != null){ + for (String key : additionalParameter.keySet()) { + countBoundSql.setAdditionalParameter(key, additionalParameter.get(key)); + } + } //异步想要起作用需要新的数据库连接,需要独立的事务,创建新的Executor,因此异步查询只适合在独立查询中使用,如果混合增删改操作,不能开启异步 Environment environment = configuration.getEnvironment(); TransactionFactory transactionFactory = null;