HHH-14876 Fix BatchLoadSizingStrategy#determineOptimalBatchLoadSize()

This commit is contained in:
Andrea Boriero 2021-10-28 15:46:25 +02:00 committed by Andrea Boriero
parent f9d0b7d069
commit 53ad8d36e2
2 changed files with 12 additions and 22 deletions

View File

@ -3074,14 +3074,18 @@ public abstract class Dialect implements ConversionContext {
if ( numberOfKeyColumns > 1 ) {
return paddedSize;
}
if ( paddedSize < getInExpressionCountLimit() ) {
final int inExpressionCountLimit = getInExpressionCountLimit();
if ( inExpressionCountLimit > 0 ) {
if ( paddedSize < inExpressionCountLimit ) {
return paddedSize;
}
else if ( numberOfKeys < getInExpressionCountLimit() ) {
else if ( numberOfKeys < inExpressionCountLimit ) {
return numberOfKeys;
}
return getInExpressionCountLimit();
}
return paddedSize;
}
};
public BatchLoadSizingStrategy getDefaultBatchLoadSizingStrategy() {

View File

@ -88,25 +88,11 @@ public class MultiLoadSubSelectCollectionTest {
assertFalse( Hibernate.isInitialized( p.children ) );
}
// When the first collection is loaded, the full batch of 50 collections
// When the first collection is loaded, the full collection
// should be loaded.
Hibernate.initialize( list.get( 0 ).children );
for ( int i = 0; i < 50; i++ ) {
assertTrue( Hibernate.isInitialized( list.get( i ).children ) );
assertEquals( i + 1, list.get( i ).children.size() );
}
// The collections for the 51st through 56th entities should still be uninitialized
for ( int i = 50; i < 56; i++ ) {
assertFalse( Hibernate.isInitialized( list.get( i ).children ) );
}
// When the 51st collection gets initialized, the remaining collections should
// also be initialized.
Hibernate.initialize( list.get( 50 ).children );
for ( int i = 50; i < 56; i++ ) {
for ( int i = 0; i < 56; i++ ) {
assertTrue( Hibernate.isInitialized( list.get( i ).children ) );
assertEquals( i + 1, list.get( i ).children.size() );
}