|
108 | 108 | import org.hibernate.internal.util.StringHelper;
|
109 | 109 | import org.hibernate.internal.util.collections.ArrayHelper;
|
110 | 110 | import org.hibernate.internal.util.io.StreamCopier;
|
111 |
| -import org.hibernate.loader.BatchLoadSizingStrategy; |
| 111 | +import org.hibernate.loader.ast.spi.MultiKeyLoadSizingStrategy; |
112 | 112 | import org.hibernate.mapping.Column;
|
113 | 113 | import org.hibernate.mapping.Constraint;
|
114 | 114 | import org.hibernate.mapping.ForeignKey;
|
|
177 | 177 | import org.hibernate.type.descriptor.jdbc.ArrayJdbcType;
|
178 | 178 | import org.hibernate.type.descriptor.jdbc.BlobJdbcType;
|
179 | 179 | import org.hibernate.type.descriptor.jdbc.ClobJdbcType;
|
180 |
| -import org.hibernate.type.descriptor.jdbc.TimeUtcAsOffsetTimeJdbcType; |
181 |
| -import org.hibernate.type.descriptor.jdbc.TimestampUtcAsJdbcTimestampJdbcType; |
182 |
| -import org.hibernate.type.descriptor.jdbc.TimestampUtcAsOffsetDateTimeJdbcType; |
183 | 180 | import org.hibernate.type.descriptor.jdbc.JdbcLiteralFormatter;
|
184 | 181 | import org.hibernate.type.descriptor.jdbc.JdbcType;
|
185 | 182 | import org.hibernate.type.descriptor.jdbc.LongNVarcharJdbcType;
|
186 | 183 | import org.hibernate.type.descriptor.jdbc.NCharJdbcType;
|
187 | 184 | import org.hibernate.type.descriptor.jdbc.NClobJdbcType;
|
188 | 185 | import org.hibernate.type.descriptor.jdbc.NVarcharJdbcType;
|
189 | 186 | import org.hibernate.type.descriptor.jdbc.TimeUtcAsJdbcTimeJdbcType;
|
| 187 | +import org.hibernate.type.descriptor.jdbc.TimeUtcAsOffsetTimeJdbcType; |
| 188 | +import org.hibernate.type.descriptor.jdbc.TimestampUtcAsJdbcTimestampJdbcType; |
| 189 | +import org.hibernate.type.descriptor.jdbc.TimestampUtcAsOffsetDateTimeJdbcType; |
190 | 190 | import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
191 | 191 | import org.hibernate.type.descriptor.sql.internal.CapacityDependentDdlType;
|
192 | 192 | import org.hibernate.type.descriptor.sql.internal.DdlTypeImpl;
|
@@ -3774,6 +3774,18 @@ public int getInExpressionCountLimit() {
|
3774 | 3774 | return 0;
|
3775 | 3775 | }
|
3776 | 3776 |
|
| 3777 | + /** |
| 3778 | + * Return the limit that the underlying database places on the number of parameters |
| 3779 | + * that can be defined for a PreparedStatement. If the database defines no such |
| 3780 | + * limits, simply return zero or a number smaller than zero. By default, Dialect |
| 3781 | + * returns the same value as {@link #getInExpressionCountLimit()}. |
| 3782 | + * |
| 3783 | + * @return The limit, or a non-positive integer to indicate no limit. |
| 3784 | + */ |
| 3785 | + public int getParameterCountLimit() { |
| 3786 | + return getInExpressionCountLimit(); |
| 3787 | + } |
| 3788 | + |
3777 | 3789 | /**
|
3778 | 3790 | * Must LOB values occur last in inserts and updates?
|
3779 | 3791 | *
|
@@ -4008,40 +4020,43 @@ public NameQualifierSupport getNameQualifierSupport() {
|
4008 | 4020 | return null;
|
4009 | 4021 | }
|
4010 | 4022 |
|
4011 |
| - protected final BatchLoadSizingStrategy STANDARD_DEFAULT_BATCH_LOAD_SIZING_STRATEGY = |
4012 |
| - (numberOfKeyColumns, numberOfKeys, inClauseParameterPaddingEnabled) -> { |
4013 |
| - final int paddedSize; |
| 4023 | + /** |
| 4024 | + * The strategy used to determine the appropriate number of keys |
| 4025 | + * to load in a single SQL query with multi-key loading. |
| 4026 | + * @see org.hibernate.Session#byMultipleIds |
| 4027 | + * @see org.hibernate.Session#byMultipleNaturalId |
| 4028 | + */ |
| 4029 | + public MultiKeyLoadSizingStrategy getMultiKeyLoadSizingStrategy() { |
| 4030 | + return STANDARD_MULTI_KEY_LOAD_SIZING_STRATEGY; |
| 4031 | + } |
4014 | 4032 |
|
4015 |
| - if ( inClauseParameterPaddingEnabled ) { |
4016 |
| - paddedSize = MathHelper.ceilingPowerOfTwo( numberOfKeys ); |
4017 |
| - } |
4018 |
| - else { |
4019 |
| - paddedSize = numberOfKeys; |
4020 |
| - } |
| 4033 | + /** |
| 4034 | + * The strategy used to determine the appropriate number of keys |
| 4035 | + * to load in a single SQL query with batch-fetch loading. |
| 4036 | + * |
| 4037 | + * @implNote By default, the same as {@linkplain #getMultiKeyLoadSizingStrategy} |
| 4038 | + * |
| 4039 | + * @see org.hibernate.annotations.BatchSize |
| 4040 | + */ |
| 4041 | + public MultiKeyLoadSizingStrategy getBatchLoadSizingStrategy() { |
| 4042 | + return getMultiKeyLoadSizingStrategy(); |
| 4043 | + } |
4021 | 4044 |
|
4022 |
| - // For tuples, there is no limit, so we can just use the power of two padding approach |
4023 |
| - if ( numberOfKeyColumns > 1 ) { |
4024 |
| - return paddedSize; |
4025 |
| - } |
4026 |
| - final int inExpressionCountLimit = getInExpressionCountLimit(); |
4027 |
| - if ( inExpressionCountLimit > 0 ) { |
4028 |
| - if ( paddedSize < inExpressionCountLimit ) { |
4029 |
| - return paddedSize; |
4030 |
| - } |
4031 |
| - else if ( numberOfKeys < inExpressionCountLimit ) { |
4032 |
| - return numberOfKeys; |
| 4045 | + protected final MultiKeyLoadSizingStrategy STANDARD_MULTI_KEY_LOAD_SIZING_STRATEGY = (numberOfColumns, numberOfKeys, pad) -> { |
| 4046 | + numberOfKeys = pad ? MathHelper.ceilingPowerOfTwo( numberOfKeys ) : numberOfKeys; |
| 4047 | + |
| 4048 | + final long parameterCount = (long) numberOfColumns * numberOfKeys; |
| 4049 | + final int limit = getParameterCountLimit(); |
| 4050 | + |
| 4051 | + if ( limit > 0 ) { |
| 4052 | + // the Dialect reported a limit - see if the parameter count exceeds the limit |
| 4053 | + if ( parameterCount >= limit ) { |
| 4054 | + return limit / numberOfColumns; |
4033 | 4055 | }
|
4034 |
| - return getInExpressionCountLimit(); |
4035 | 4056 | }
|
4036 |
| - return paddedSize; |
4037 |
| - }; |
4038 | 4057 |
|
4039 |
| - /** |
4040 |
| - * The strategy to use for determining batch sizes in batch loading. |
4041 |
| - */ |
4042 |
| - public BatchLoadSizingStrategy getDefaultBatchLoadSizingStrategy() { |
4043 |
| - return STANDARD_DEFAULT_BATCH_LOAD_SIZING_STRATEGY; |
4044 |
| - } |
| 4058 | + return numberOfKeys; |
| 4059 | + }; |
4045 | 4060 |
|
4046 | 4061 | /**
|
4047 | 4062 | * Is JDBC statement warning logging enabled by default?
|
|
0 commit comments