This commit is contained in:
Looly
2024-07-05 13:17:54 +08:00
parent c054d025dd
commit 47b21b951f
8 changed files with 140 additions and 68 deletions

View File

@@ -97,6 +97,17 @@ public class StatementBuilder implements Builder<StatementWrapper> {
return this;
}
/**
* 设置SQL的"?"对应的参数
*
* @param params 参数列表
* @return this
*/
public StatementBuilder setParamList(final List<Object> params) {
this.boundSql.setParams(params);
return this;
}
/**
* 设置是否返回主键
*

View File

@@ -12,11 +12,11 @@
package org.dromara.hutool.db.sql;
import org.dromara.hutool.core.array.ArrayUtil;
import org.dromara.hutool.core.collection.iter.ArrayIter;
import org.dromara.hutool.core.io.IoUtil;
import org.dromara.hutool.core.lang.Assert;
import org.dromara.hutool.core.lang.Opt;
import org.dromara.hutool.core.stream.StreamUtil;
import org.dromara.hutool.db.DbException;
import org.dromara.hutool.db.config.DbConfig;
import org.dromara.hutool.db.handler.ResultSetUtil;
@@ -25,6 +25,7 @@ import org.dromara.hutool.db.handler.RsHandler;
import java.sql.*;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Statement和PreparedStatement工具类
@@ -86,7 +87,7 @@ public class StatementUtil {
.setReturnGeneratedKey(false)
.setSqlFilter(Opt.ofNullable(config).map(DbConfig::getSqlFilters).get())
.setSql(sql)
.setParams(ArrayUtil.ofArray(paramsBatch, Object.class))
.setParamList(StreamUtil.of(paramsBatch).collect(Collectors.toList()))
.buildForBatch();
}