mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix bug
This commit is contained in:
@@ -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>
|
||||
|
@@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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");
|
||||
|
Reference in New Issue
Block a user