mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix db bug
This commit is contained in:
@@ -21,7 +21,7 @@ public class DbTest {
|
||||
List<Entity> find = Db.use().query("select * from user where age = ?", 18);
|
||||
Assert.assertEquals("王五", find.get(0).get("name"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void findTest() throws SQLException {
|
||||
List<Entity> find = Db.use().find(Entity.create("user").set("age", 18));
|
||||
@@ -39,7 +39,7 @@ public class DbTest {
|
||||
|
||||
@Test
|
||||
public void pageTest2() throws SQLException {
|
||||
String sql = "select * from user";
|
||||
String sql = "select * from user order by name";
|
||||
// 测试数据库中一共4条数据,第0页有3条,第1页有1条
|
||||
List<Entity> page0 = Db.use().page(
|
||||
sql, Page.of(0, 3));
|
||||
@@ -56,6 +56,12 @@ public class DbTest {
|
||||
Assert.assertEquals(4, count);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void countTest2() throws SQLException {
|
||||
final long count = Db.use().count("select * from user order by name DESC");
|
||||
Assert.assertEquals(4, count);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findLikeTest() throws SQLException {
|
||||
// 方式1
|
||||
@@ -74,7 +80,7 @@ public class DbTest {
|
||||
@Test
|
||||
public void findByTest() throws SQLException {
|
||||
List<Entity> find = Db.use().findBy("user",
|
||||
Condition.parse("age", "> 18"),
|
||||
Condition.parse("age", "> 18"),
|
||||
Condition.parse("age", "< 100")
|
||||
);
|
||||
for (Entity entity : find) {
|
||||
@@ -82,7 +88,7 @@ public class DbTest {
|
||||
}
|
||||
Assert.assertEquals("unitTestUser", find.get(0).get("name"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void txTest() throws SQLException {
|
||||
|
Reference in New Issue
Block a user