|
71 | 71 | import org.hibernate.exception.spi.SQLExceptionConverter;
|
72 | 72 | import org.hibernate.exception.spi.ViolatedConstraintNameExtractor;
|
73 | 73 | import org.hibernate.internal.CoreMessageLogger;
|
74 |
| -import org.hibernate.internal.util.MathHelper; |
75 | 74 | import org.hibernate.internal.util.StringHelper;
|
76 | 75 | import org.hibernate.internal.util.collections.ArrayHelper;
|
77 | 76 | import org.hibernate.loader.ast.spi.MultiKeyLoadSizingStrategy;
|
|
208 | 207 | import static org.hibernate.cfg.AvailableSettings.NON_CONTEXTUAL_LOB_CREATION;
|
209 | 208 | import static org.hibernate.cfg.AvailableSettings.STATEMENT_BATCH_SIZE;
|
210 | 209 | import static org.hibernate.cfg.AvailableSettings.USE_GET_GENERATED_KEYS;
|
| 210 | +import static org.hibernate.internal.util.MathHelper.ceilingPowerOfTwo; |
211 | 211 | import static org.hibernate.internal.util.StringHelper.splitAtCommas;
|
212 | 212 | import static org.hibernate.internal.util.collections.ArrayHelper.EMPTY_STRING_ARRAY;
|
213 | 213 | import static org.hibernate.type.SqlTypes.*;
|
@@ -4385,21 +4385,13 @@ public MultiKeyLoadSizingStrategy getBatchLoadSizingStrategy() {
|
4385 | 4385 | return getMultiKeyLoadSizingStrategy();
|
4386 | 4386 | }
|
4387 | 4387 |
|
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 | + } |
4400 | 4393 |
|
4401 |
| - return numberOfKeys; |
4402 |
| - }; |
| 4394 | + protected final MultiKeyLoadSizingStrategy STANDARD_MULTI_KEY_LOAD_SIZING_STRATEGY = this::calculateBatchSize; |
4403 | 4395 |
|
4404 | 4396 | /**
|
4405 | 4397 | * Is JDBC statement warning logging enabled by default?
|
|
0 commit comments