HHH-16570 Batch fetch with FetchMode JOIN might lead to multiplication in OneToMany items

This commit is contained in:
Andrea Boriero 2023-05-18 14:44:44 +02:00 committed by Christian Beikov
parent 87fc258109
commit 62c05eadb9
1 changed files with 8 additions and 9 deletions

View File

@ -354,6 +354,14 @@ public class LoaderSelectBuilder {
this.entityGraphTraversalState = entityGraphTraversalState;
this.forceIdentifierSelection = forceIdentifierSelection;
this.jdbcParameterConsumer = jdbcParameterConsumer;
if ( loadable instanceof PluralAttributeMapping ) {
final PluralAttributeMapping pluralAttributeMapping = (PluralAttributeMapping) loadable;
if ( pluralAttributeMapping.getMappedType()
.getCollectionSemantics()
.getCollectionClassification() == CollectionClassification.BAG ) {
rowCardinality = RowCardinality.BAG;
}
}
}
private LoaderSelectBuilder(
@ -440,15 +448,6 @@ public class LoaderSelectBuilder {
}
private SelectStatement generateSelect() {
if ( loadable instanceof PluralAttributeMapping ) {
final PluralAttributeMapping pluralAttributeMapping = (PluralAttributeMapping) loadable;
if ( pluralAttributeMapping.getMappedType()
.getCollectionSemantics()
.getCollectionClassification() == CollectionClassification.BAG ) {
rowCardinality = RowCardinality.BAG;
}
}
final NavigablePath rootNavigablePath = new NavigablePath( loadable.getRootPathName() );
final QuerySpec rootQuerySpec = new QuerySpec( true );