Skip to content

Commit ae53810

Browse files
committed
minor cleanup in Dialect
Signed-off-by: Gavin King <[email protected]>
1 parent 9828ad7 commit ae53810

File tree

1 file changed

+7
-15
lines changed
  • hibernate-core/src/main/java/org/hibernate/dialect

1 file changed

+7
-15
lines changed

hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
import org.hibernate.exception.spi.SQLExceptionConverter;
7272
import org.hibernate.exception.spi.ViolatedConstraintNameExtractor;
7373
import org.hibernate.internal.CoreMessageLogger;
74-
import org.hibernate.internal.util.MathHelper;
7574
import org.hibernate.internal.util.StringHelper;
7675
import org.hibernate.internal.util.collections.ArrayHelper;
7776
import org.hibernate.loader.ast.spi.MultiKeyLoadSizingStrategy;
@@ -208,6 +207,7 @@
208207
import static org.hibernate.cfg.AvailableSettings.NON_CONTEXTUAL_LOB_CREATION;
209208
import static org.hibernate.cfg.AvailableSettings.STATEMENT_BATCH_SIZE;
210209
import static org.hibernate.cfg.AvailableSettings.USE_GET_GENERATED_KEYS;
210+
import static org.hibernate.internal.util.MathHelper.ceilingPowerOfTwo;
211211
import static org.hibernate.internal.util.StringHelper.splitAtCommas;
212212
import static org.hibernate.internal.util.collections.ArrayHelper.EMPTY_STRING_ARRAY;
213213
import static org.hibernate.type.SqlTypes.*;
@@ -4385,21 +4385,13 @@ public MultiKeyLoadSizingStrategy getBatchLoadSizingStrategy() {
43854385
return getMultiKeyLoadSizingStrategy();
43864386
}
43874387

4388-
protected final MultiKeyLoadSizingStrategy STANDARD_MULTI_KEY_LOAD_SIZING_STRATEGY = (numberOfColumns, numberOfKeys, pad) -> {
4389-
numberOfKeys = pad ? MathHelper.ceilingPowerOfTwo( numberOfKeys ) : numberOfKeys;
4390-
4391-
final long parameterCount = (long) numberOfColumns * numberOfKeys;
4392-
final int limit = getParameterCountLimit();
4393-
4394-
if ( limit > 0 ) {
4395-
// the Dialect reported a limit - see if the parameter count exceeds the limit
4396-
if ( parameterCount >= limit ) {
4397-
return limit / numberOfColumns;
4398-
}
4399-
}
4388+
private int calculateBatchSize(int numberOfColumns, int numberOfKeys, boolean padToPowerOfTwo) {
4389+
final int batchSize = padToPowerOfTwo ? ceilingPowerOfTwo( numberOfKeys ) : numberOfKeys;
4390+
final int maxBatchSize = getParameterCountLimit() / numberOfColumns;
4391+
return maxBatchSize > 0 && batchSize > maxBatchSize ? maxBatchSize : batchSize;
4392+
}
44004393

4401-
return numberOfKeys;
4402-
};
4394+
protected final MultiKeyLoadSizingStrategy STANDARD_MULTI_KEY_LOAD_SIZING_STRATEGY = this::calculateBatchSize;
44034395

44044396
/**
44054397
* Is JDBC statement warning logging enabled by default?

0 commit comments

Comments
 (0)