mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add setFetchSize and FetchDirection
This commit is contained in:
@@ -101,13 +101,28 @@ public class StatementUtil {
|
|||||||
*/
|
*/
|
||||||
public static PreparedStatement prepareStatementForBatch(final DbConfig config, final Connection conn, final String sql,
|
public static PreparedStatement prepareStatementForBatch(final DbConfig config, final Connection conn, final String sql,
|
||||||
final Iterable<Object[]> paramsBatch) {
|
final Iterable<Object[]> paramsBatch) {
|
||||||
return StatementBuilder.of()
|
PreparedStatement statement = StatementBuilder.of()
|
||||||
.setConnection(conn)
|
.setConnection(conn)
|
||||||
.setReturnGeneratedKey(false)
|
.setReturnGeneratedKey(false)
|
||||||
.setSqlFilter(Opt.ofNullable(config).map(DbConfig::getSqlFilters).getOrNull())
|
.setSqlFilter(Opt.ofNullable(config).map(DbConfig::getSqlFilters).getOrNull())
|
||||||
.setSql(sql)
|
.setSql(sql)
|
||||||
.setParamList(StreamUtil.of(paramsBatch).collect(Collectors.toList()))
|
.setParamList(StreamUtil.of(paramsBatch).collect(Collectors.toList()))
|
||||||
.buildForBatch();
|
.buildForBatch();
|
||||||
|
|
||||||
|
try{
|
||||||
|
final Integer fetchSize = config.getFetchSize();
|
||||||
|
if (null != fetchSize) {
|
||||||
|
statement.setFetchSize(fetchSize);
|
||||||
|
}
|
||||||
|
final FetchDirection fetchDirection = config.getFetchDirection();
|
||||||
|
if (null != fetchDirection) {
|
||||||
|
statement.setFetchDirection(fetchDirection.getValue());
|
||||||
|
}
|
||||||
|
} catch (SQLException e){
|
||||||
|
throw new DbException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return statement;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user