This commit is contained in:
Looly 2022-05-26 12:12:05 +08:00
parent 268f258537
commit 969a017f02
4 changed files with 15 additions and 10 deletions

View File

@ -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方法抛出运行时异常增加InvocationTargetRuntimeExceptionissue#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

View File

@ -22,12 +22,12 @@
<dbcp2.version>2.9.0</dbcp2.version>
<tomcat-jdbc.version>10.0.20</tomcat-jdbc.version>
<druid.version>1.2.9</druid.version>
<hikariCP.version>2.4.13</hikariCP.version>
<hikariCP.version>4.0.3</hikariCP.version>
<mongo4.version>4.6.0</mongo4.version>
<sqlite.version>3.36.0.3</sqlite.version>
<!-- 此处固定2.5.x支持到JDK8 -->
<hsqldb.version>2.5.2</hsqldb.version>
<jedis.version>4.2.2</jedis.version>
<jedis.version>4.2.3</jedis.version>
</properties>
<dependencies>
@ -62,7 +62,7 @@
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP-java7</artifactId>
<artifactId>HikariCP</artifactId>
<version>${hikariCP.version}</version>
<exclusions>
<exclusion>
@ -156,7 +156,7 @@
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>10.2.0.jre8</version>
<version>10.2.1.jre8</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -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));
}
/**

View File

@ -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");