From ddc4fdb2c6339853d381288733a0342d735de3e0 Mon Sep 17 00:00:00 2001 From: Looly Date: Tue, 15 Aug 2023 10:27:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DDb.findAll=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E5=BF=BD=E7=95=A5=E5=A4=A7=E5=B0=8F=E5=86=99=E6=97=A0=E6=95=88?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + hutool-db/src/main/java/cn/hutool/db/AbstractDb.java | 2 +- hutool-db/src/test/java/cn/hutool/db/CRUDTest.java | 2 +- .../src/test/java/cn/hutool/db/ConcurentTest.java | 12 ++++++------ hutool-db/src/test/java/cn/hutool/db/DbTest.java | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b951f4175..7e56b43c3 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ * 【core 】 修复DateUtil.parse 给定一个时间解析错误问题(issue#I7QI6R@Gitee) * 【core 】 去除默认的ACCEPT_LANGUAGE(issue#3258@Github) * 【core 】 修复FieldsComparator比较结果不正确问题(issue#3259@Github) +* 【core 】 修复Db.findAll全局忽略大小写无效问题(issue#I7T30Y@Gitee) ------------------------------------------------------------------------------------------------------------- # 5.8.21(2023-07-29) diff --git a/hutool-db/src/main/java/cn/hutool/db/AbstractDb.java b/hutool-db/src/main/java/cn/hutool/db/AbstractDb.java index beee6c8a4..a5069aff1 100755 --- a/hutool-db/src/main/java/cn/hutool/db/AbstractDb.java +++ b/hutool-db/src/main/java/cn/hutool/db/AbstractDb.java @@ -624,7 +624,7 @@ public abstract class AbstractDb implements Serializable { * @throws SQLException SQL执行异常 */ public List findAll(Entity where) throws SQLException { - return find(where, EntityListHandler.create()); + return find(where, new EntityListHandler(this.caseInsensitive)); } /** diff --git a/hutool-db/src/test/java/cn/hutool/db/CRUDTest.java b/hutool-db/src/test/java/cn/hutool/db/CRUDTest.java index d81502707..3a357fa7e 100644 --- a/hutool-db/src/test/java/cn/hutool/db/CRUDTest.java +++ b/hutool-db/src/test/java/cn/hutool/db/CRUDTest.java @@ -108,7 +108,7 @@ public class CRUDTest { @Test public void findTest() throws SQLException { - List find = db.find(CollUtil.newArrayList("name AS name2"), Entity.create("user"), new EntityListHandler()); + List find = db.find(CollUtil.newArrayList("name AS name2"), Entity.create("user"), EntityListHandler.create()); Assert.assertFalse(find.isEmpty()); } diff --git a/hutool-db/src/test/java/cn/hutool/db/ConcurentTest.java b/hutool-db/src/test/java/cn/hutool/db/ConcurentTest.java index f861cbd3e..b5b5450cc 100755 --- a/hutool-db/src/test/java/cn/hutool/db/ConcurentTest.java +++ b/hutool-db/src/test/java/cn/hutool/db/ConcurentTest.java @@ -13,34 +13,34 @@ import java.util.List; /** * SqlRunner线程安全测试 - * + * * @author looly * */ @Ignore public class ConcurentTest { - + private Db db; - + @Before public void init() { db = Db.use("test"); } - + @Test public void findTest() { for(int i = 0; i < 10000; i++) { ThreadUtil.execute(() -> { List find; try { - find = db.find(CollectionUtil.newArrayList("name AS name2"), Entity.create("user"), new EntityListHandler()); + find = db.find(CollectionUtil.newArrayList("name AS name2"), Entity.create("user"), EntityListHandler.create()); } catch (SQLException e) { throw new DbRuntimeException(e); } Console.log(find); }); } - + //主线程关闭会导致连接池销毁,sleep避免此情况引起的问题 ThreadUtil.sleep(5000); } 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 6b43f5d7c..83350017c 100644 --- a/hutool-db/src/test/java/cn/hutool/db/DbTest.java +++ b/hutool-db/src/test/java/cn/hutool/db/DbTest.java @@ -130,7 +130,7 @@ public class DbTest { ps.setFetchSize(Integer.MIN_VALUE); ps.setFetchDirection(ResultSet.FETCH_FORWARD); return ps; - }), new EntityListHandler()); + }), EntityListHandler.create()); } @Test