diff --git a/CHANGELOG.md b/CHANGELOG.md
index 61c4e7e30..427d9eff4 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,20 +3,21 @@
-------------------------------------------------------------------------------------------------------------
-# 5.8.2.M1 (2022-05-24)
+# 5.8.2.M1 (2022-05-26)
### 🐣新特性
* 【core 】 BeanUtil拷贝对象增加空检查(issue#I58CJ3@Gitee)
* 【db 】 Column#size改为long
* 【core 】 ClassUtil增加isInterface等方法(pr#623@Gitee)
* 【socket 】 增加ChannelUtil
-*
+
### 🐞Bug修复
* 【extra 】 修复SshjSftp初始化未能代入端口配置问题(issue#2333@Github)
* 【core 】 修复Convert.numberToSimple转换问题(issue#2334@Github)
* 【core 】 修复TemporalAccessorConverter导致的转换问题(issue#2341@Github)
* 【core 】 修复NumberUtil除法空指针问题(issue#I58XKE@Gitee)
* 【core 】 修复CAR_VIN正则(pr#624@Gitee)
+* 【db 】 修复count查询别名问题(issue#I590YB@Gitee)
-------------------------------------------------------------------------------------------------------------
@@ -30,7 +31,7 @@
* 【core 】 ByteUtil新增bytesToShort重载(issue#I57FA7@Gitee)
* 【core 】 ReflectUtil.invoke方法抛出运行时异常增加InvocationTargetRuntimeException(issue#I57GI2@Gitee)
* 【core 】 NumberUtil.parseNumber支持16进制(issue#2328@Github)
-*
+
### 🐞Bug修复
* 【core 】 MapUtil.map对null友好,且修复了测试用例中分组问题(pr#614@Gitee)
* 【core 】 修复BeanUtil.beanToMap中properties为null的空指针问题(issue#2303@Github)
diff --git a/hutool-db/pom.xml b/hutool-db/pom.xml
index b8f5947ed..f28ddc47a 100755
--- a/hutool-db/pom.xml
+++ b/hutool-db/pom.xml
@@ -22,12 +22,12 @@
2.9.0
10.0.20
1.2.9
- 2.4.13
+ 4.0.3
4.6.0
3.36.0.3
2.5.2
- 4.2.2
+ 4.2.3
@@ -62,7 +62,7 @@
com.zaxxer
- HikariCP-java7
+ HikariCP
${hikariCP.version}
@@ -156,7 +156,7 @@
com.microsoft.sqlserver
mssql-jdbc
- 10.2.0.jre8
+ 10.2.1.jre8
test
diff --git a/hutool-db/src/main/java/cn/hutool/db/dialect/Dialect.java b/hutool-db/src/main/java/cn/hutool/db/dialect/Dialect.java
index 6ad5922bd..7f0ca07a5 100644
--- a/hutool-db/src/main/java/cn/hutool/db/dialect/Dialect.java
+++ b/hutool-db/src/main/java/cn/hutool/db/dialect/Dialect.java
@@ -1,6 +1,5 @@
package cn.hutool.db.dialect;
-import cn.hutool.core.collection.ListUtil;
import cn.hutool.db.Entity;
import cn.hutool.db.Page;
import cn.hutool.db.sql.Order;
@@ -134,8 +133,7 @@ public interface Dialect extends Serializable {
* @throws SQLException SQL执行异常
*/
default PreparedStatement psForCount(Connection conn, Query query) throws SQLException {
- query.setFields(ListUtil.toList("count(1)"));
- return psForFind(conn, query);
+ return psForCount(conn, SqlBuilder.create().query(query));
}
/**
diff --git a/hutool-db/src/test/java/cn/hutool/db/DbTest.java b/hutool-db/src/test/java/cn/hutool/db/DbTest.java
index 1002b602e..5419097a2 100644
--- a/hutool-db/src/test/java/cn/hutool/db/DbTest.java
+++ b/hutool-db/src/test/java/cn/hutool/db/DbTest.java
@@ -70,6 +70,12 @@ public class DbTest {
Assert.assertEquals(4, count);
}
+ @Test
+ public void countByQueryTest() throws SQLException {
+ final long count = Db.use().count(Entity.create("user"));
+ Assert.assertEquals(4, count);
+ }
+
@Test
public void countTest2() throws SQLException {
final long count = Db.use().count("select * from user order by name DESC");