mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix pr#1023
This commit is contained in:
@@ -36,7 +36,6 @@ import java.util.Set;
|
||||
* ANSI SQL 方言
|
||||
*
|
||||
* @author loolly
|
||||
*
|
||||
*/
|
||||
public class AnsiSqlDialect implements Dialect {
|
||||
private static final long serialVersionUID = 2088101129774974580L;
|
||||
@@ -67,7 +66,7 @@ public class AnsiSqlDialect implements Dialect {
|
||||
}
|
||||
// 批量,根据第一行数据结构生成SQL占位符
|
||||
final SqlBuilder insert = SqlBuilder.of(quoteWrapper).insert(entities[0], this.dialectName());
|
||||
final Set<String> fields=CollUtil.remove(entities[0].keySet(),StrUtil::isBlank);
|
||||
final Set<String> fields = CollUtil.remove(entities[0].keySet(), StrUtil::isBlank);
|
||||
return StatementUtil.prepareStatementForBatch(conn, insert.build(), fields, entities);
|
||||
}
|
||||
|
||||
@@ -119,7 +118,7 @@ public class AnsiSqlDialect implements Dialect {
|
||||
@Override
|
||||
public PreparedStatement psForPage(final Connection conn, SqlBuilder sqlBuilder, final Page page) throws SQLException {
|
||||
// 根据不同数据库在查询SQL语句基础上包装其分页的语句
|
||||
if(null != page){
|
||||
if (null != page) {
|
||||
sqlBuilder = wrapPageSql(sqlBuilder.orderBy(page.getOrders()), page);
|
||||
}
|
||||
return StatementUtil.prepareStatement(conn, sqlBuilder);
|
||||
|
@@ -137,31 +137,33 @@ public class DbTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void batchInsert() throws SQLException {
|
||||
List<Entity> es = new ArrayList<>();
|
||||
String tableName = "act_ge_property";
|
||||
Entity e = buildEntity(tableName);
|
||||
@Disabled
|
||||
public void batchInsertTest() throws SQLException {
|
||||
final List<Entity> es = new ArrayList<>();
|
||||
final String tableName = "act_ge_property";
|
||||
final Entity e = buildEntity();
|
||||
es.add(e);
|
||||
Db.of().tx(db -> {
|
||||
db.insert(es);
|
||||
List<Entity> ens = Db.of().find(e);
|
||||
final List<Entity> ens = Db.of().find(e);
|
||||
Assertions.assertEquals(1, ens.size());
|
||||
db.del(tableName, "NAME_", "!= null");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled
|
||||
public void batchInsertBatch() throws SQLException {
|
||||
List<Entity> es = new ArrayList<>();
|
||||
String tableName = "act_ge_property";
|
||||
Entity e = buildEntity(tableName);
|
||||
final List<Entity> es = new ArrayList<>();
|
||||
final String tableName = "act_ge_property";
|
||||
final Entity e = buildEntity();
|
||||
es.add(e);
|
||||
es.add(buildEntity(tableName));
|
||||
es.add(buildEntity(tableName));
|
||||
es.add(buildEntity(tableName));
|
||||
es.add(buildEntity());
|
||||
es.add(buildEntity());
|
||||
es.add(buildEntity());
|
||||
Db.of().tx(db -> {
|
||||
db.insert(es);
|
||||
List<Entity> ens = Db.of().find(e);
|
||||
final List<Entity> ens = Db.of().find(e);
|
||||
Assertions.assertEquals(1, ens.size());
|
||||
db.del(tableName, "NAME_", "!= null");
|
||||
});
|
||||
@@ -169,8 +171,8 @@ public class DbTest {
|
||||
|
||||
}
|
||||
|
||||
private Entity buildEntity(String tableName) {
|
||||
Entity entity = Entity.of("act_ge_property");
|
||||
private Entity buildEntity() {
|
||||
final Entity entity = Entity.of("act_ge_property");
|
||||
entity.put("NAME_", RandomUtil.randomString(15));
|
||||
entity.put("VALUE_", RandomUtil.randomString(50));
|
||||
entity.put("REV_", RandomUtil.randomInt());
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user