Skip to content

Commit 62c05ea

Browse files
dreab8beikov
authored andcommitted
HHH-16570 Batch fetch with FetchMode JOIN might lead to multiplication in OneToMany items
1 parent 87fc258 commit 62c05ea

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSelectBuilder.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,14 @@ private LoaderSelectBuilder(
354354
this.entityGraphTraversalState = entityGraphTraversalState;
355355
this.forceIdentifierSelection = forceIdentifierSelection;
356356
this.jdbcParameterConsumer = jdbcParameterConsumer;
357+
if ( loadable instanceof PluralAttributeMapping ) {
358+
final PluralAttributeMapping pluralAttributeMapping = (PluralAttributeMapping) loadable;
359+
if ( pluralAttributeMapping.getMappedType()
360+
.getCollectionSemantics()
361+
.getCollectionClassification() == CollectionClassification.BAG ) {
362+
rowCardinality = RowCardinality.BAG;
363+
}
364+
}
357365
}
358366

359367
private LoaderSelectBuilder(
@@ -440,15 +448,6 @@ private static EntityGraphTraversalState determineGraphTraversalState(LoadQueryI
440448
}
441449

442450
private SelectStatement generateSelect() {
443-
if ( loadable instanceof PluralAttributeMapping ) {
444-
final PluralAttributeMapping pluralAttributeMapping = (PluralAttributeMapping) loadable;
445-
if ( pluralAttributeMapping.getMappedType()
446-
.getCollectionSemantics()
447-
.getCollectionClassification() == CollectionClassification.BAG ) {
448-
rowCardinality = RowCardinality.BAG;
449-
}
450-
}
451-
452451
final NavigablePath rootNavigablePath = new NavigablePath( loadable.getRootPathName() );
453452

454453
final QuerySpec rootQuerySpec = new QuerySpec( true );

0 commit comments

Comments
 (0)