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 4dd37075ee
commit 87f0dfc9d6
1 changed files with 8 additions and 9 deletions

View File

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