diff --git a/hibernate-core/src/main/java/org/hibernate/query/results/TableGroupImpl.java b/hibernate-core/src/main/java/org/hibernate/query/results/TableGroupImpl.java index b99d250c45..a187f0e2fd 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/results/TableGroupImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/results/TableGroupImpl.java @@ -8,7 +8,6 @@ import java.util.Collections; import java.util.List; -import java.util.Set; import java.util.function.Consumer; import java.util.function.Supplier; @@ -35,7 +34,6 @@ public class TableGroupImpl implements TableGroup { private final ModelPartContainer container; private final LockMode lockMode; - private Set tableGroupJoins; public TableGroupImpl( NavigablePath navigablePath, @@ -76,32 +74,22 @@ public LockMode getLockMode() { } @Override - public Set getTableGroupJoins() { - return tableGroupJoins == null ? Collections.emptySet() : tableGroupJoins; + public List getTableGroupJoins() { + return Collections.emptyList(); } @Override public boolean hasTableGroupJoins() { - return tableGroupJoins != null && ! tableGroupJoins.isEmpty(); - } - - @Override - public void setTableGroupJoins(Set joins) { - throw new UnsupportedOperationException(); + return false; } @Override public void addTableGroupJoin(TableGroupJoin join) { - + throw new UnsupportedOperationException(); } @Override public void visitTableGroupJoins(Consumer consumer) { - if ( tableGroupJoins == null ) { - return; - } - - tableGroupJoins.forEach( consumer ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlTreePrinter.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlTreePrinter.java index 9f5cd9c5e9..ae4dee387a 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlTreePrinter.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlTreePrinter.java @@ -7,7 +7,6 @@ package org.hibernate.sql.ast; import java.util.List; -import java.util.Set; import org.hibernate.sql.ast.tree.SqlAstTreeLogger; import org.hibernate.sql.ast.tree.Statement; @@ -130,7 +129,7 @@ private void logTableGroupDetails(TableGroup tableGroup) { ); } - final Set tableGroupJoins = tableGroup.getTableGroupJoins(); + final List tableGroupJoins = tableGroup.getTableGroupJoins(); if ( ! tableGroupJoins.isEmpty() ) { logNode( "TableGroupJoins", diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/cte/CteTableGroup.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/cte/CteTableGroup.java index ad049fb6b5..2f0664268e 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/cte/CteTableGroup.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/cte/CteTableGroup.java @@ -8,7 +8,6 @@ import java.util.Collections; import java.util.List; -import java.util.Set; import java.util.function.Consumer; import java.util.function.Supplier; @@ -58,8 +57,8 @@ public ModelPart getExpressionType() { } @Override - public Set getTableGroupJoins() { - return Collections.emptySet(); + public List getTableGroupJoins() { + return Collections.emptyList(); } @Override @@ -82,10 +81,6 @@ public TableReference resolveTableReference( return cteTableReference; } - @Override - public void setTableGroupJoins(Set joins) { - } - @Override public void visitTableGroupJoins(Consumer consumer) { } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/AbstractTableGroup.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/AbstractTableGroup.java index 18ea31ef35..bb2dc697a2 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/AbstractTableGroup.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/AbstractTableGroup.java @@ -6,9 +6,9 @@ */ package org.hibernate.sql.ast.tree.from; +import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; -import java.util.Set; +import java.util.List; import java.util.function.Consumer; import org.hibernate.LockMode; @@ -26,7 +26,7 @@ public abstract class AbstractTableGroup extends AbstractColumnReferenceQualifie private final LockMode lockMode; private final SqlAliasBase sqlAliasBase; - private Set tableGroupJoins; + private List tableGroupJoins; private boolean isInnerJoinPossible; private final SessionFactoryImplementor sessionFactory; @@ -93,8 +93,8 @@ protected SessionFactoryImplementor getSessionFactory() { } @Override - public Set getTableGroupJoins() { - return tableGroupJoins == null ? Collections.emptySet() : Collections.unmodifiableSet( tableGroupJoins ); + public List getTableGroupJoins() { + return tableGroupJoins == null ? Collections.emptyList() : Collections.unmodifiableList( tableGroupJoins ); } @Override @@ -102,17 +102,14 @@ public boolean hasTableGroupJoins() { return tableGroupJoins != null && !tableGroupJoins.isEmpty(); } - @Override - public void setTableGroupJoins(Set joins) { - tableGroupJoins = new HashSet<>( joins ); - } - @Override public void addTableGroupJoin(TableGroupJoin join) { if ( tableGroupJoins == null ) { - tableGroupJoins = new HashSet<>(); + tableGroupJoins = new ArrayList<>(); + } + if ( !tableGroupJoins.contains( join ) ) { + tableGroupJoins.add( join ); } - tableGroupJoins.add( join ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/CompositeTableGroup.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/CompositeTableGroup.java index 2c835e99c3..7f2a3705df 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/CompositeTableGroup.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/CompositeTableGroup.java @@ -6,10 +6,9 @@ */ package org.hibernate.sql.ast.tree.from; +import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; import java.util.List; -import java.util.Set; import java.util.function.Consumer; import java.util.function.Supplier; @@ -26,7 +25,7 @@ public class CompositeTableGroup implements VirtualTableGroup { private final TableGroup underlyingTableGroup; - private Set tableGroupJoins; + private List tableGroupJoins; public CompositeTableGroup( NavigablePath navigablePath, @@ -64,8 +63,8 @@ public LockMode getLockMode() { } @Override - public Set getTableGroupJoins() { - return tableGroupJoins == null ? Collections.emptySet() : Collections.unmodifiableSet( tableGroupJoins ); + public List getTableGroupJoins() { + return tableGroupJoins == null ? Collections.emptyList() : Collections.unmodifiableList( tableGroupJoins ); } @Override @@ -73,17 +72,14 @@ public boolean hasTableGroupJoins() { return tableGroupJoins != null && !tableGroupJoins.isEmpty(); } - @Override - public void setTableGroupJoins(Set joins) { - tableGroupJoins = new HashSet<>( joins ); - } - @Override public void addTableGroupJoin(TableGroupJoin join) { if ( tableGroupJoins == null ) { - tableGroupJoins = new HashSet<>(); + tableGroupJoins = new ArrayList<>(); + } + if ( !tableGroupJoins.contains( join ) ) { + tableGroupJoins.add( join ); } - tableGroupJoins.add( join ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/MutatingTableReferenceGroupWrapper.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/MutatingTableReferenceGroupWrapper.java index b87b6a64a6..5a05de3cc7 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/MutatingTableReferenceGroupWrapper.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/MutatingTableReferenceGroupWrapper.java @@ -8,7 +8,6 @@ import java.util.Collections; import java.util.List; -import java.util.Set; import java.util.function.Consumer; import java.util.function.Supplier; @@ -90,8 +89,8 @@ public LockMode getLockMode() { } @Override - public Set getTableGroupJoins() { - return Collections.emptySet(); + public List getTableGroupJoins() { + return Collections.emptyList(); } @Override @@ -99,11 +98,6 @@ public boolean hasTableGroupJoins() { return false; } - @Override - public void setTableGroupJoins(Set joins) { - throw new UnsupportedOperationException(); - } - @Override public void addTableGroupJoin(TableGroupJoin join) { throw new UnsupportedOperationException(); diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableGroup.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableGroup.java index 4a262bd13c..ca0c88edb6 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableGroup.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableGroup.java @@ -12,7 +12,6 @@ import org.hibernate.LockMode; import org.hibernate.metamodel.mapping.ModelPartContainer; -import org.hibernate.persister.entity.EntityPersister; import org.hibernate.query.NavigablePath; import org.hibernate.query.sqm.sql.internal.DomainResultProducer; import org.hibernate.query.sqm.sql.internal.SqmPathInterpretation; @@ -41,12 +40,10 @@ public interface TableGroup extends SqlAstNode, ColumnReferenceQualifier, SqmPat LockMode getLockMode(); - Set getTableGroupJoins(); + List getTableGroupJoins(); boolean hasTableGroupJoins(); - void setTableGroupJoins(Set joins); - void addTableGroupJoin(TableGroupJoin join); void visitTableGroupJoins(Consumer consumer); diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/UnionTableGroup.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/UnionTableGroup.java index 87e497a5be..5044fbcedb 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/UnionTableGroup.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/UnionTableGroup.java @@ -6,10 +6,9 @@ */ package org.hibernate.sql.ast.tree.from; +import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; import java.util.List; -import java.util.Set; import java.util.function.Consumer; import java.util.function.Supplier; @@ -24,7 +23,7 @@ */ public class UnionTableGroup implements VirtualTableGroup { private final NavigablePath navigablePath; - private Set tableGroupJoins; + private List tableGroupJoins; private final UnionSubclassEntityPersister modelPart; private final TableReference tableReference; @@ -64,8 +63,8 @@ public LockMode getLockMode() { } @Override - public Set getTableGroupJoins() { - return tableGroupJoins == null ? Collections.emptySet() : Collections.unmodifiableSet( tableGroupJoins ); + public List getTableGroupJoins() { + return tableGroupJoins == null ? Collections.emptyList() : Collections.unmodifiableList( tableGroupJoins ); } @Override @@ -73,17 +72,14 @@ public boolean hasTableGroupJoins() { return tableGroupJoins != null && !tableGroupJoins.isEmpty(); } - @Override - public void setTableGroupJoins(Set joins) { - tableGroupJoins = new HashSet<>( joins ); - } - @Override public void addTableGroupJoin(TableGroupJoin join) { if ( tableGroupJoins == null ) { - tableGroupJoins = new HashSet<>(); + tableGroupJoins = new ArrayList<>(); + } + if ( !tableGroupJoins.contains( join ) ) { + tableGroupJoins.add( join ); } - tableGroupJoins.add( join ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/EntityCollectionPartTableGroup.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/EntityCollectionPartTableGroup.java index 89d486f2c6..7c61f5833d 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/EntityCollectionPartTableGroup.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/EntityCollectionPartTableGroup.java @@ -7,7 +7,6 @@ package org.hibernate.sql.results.graph.collection.internal; import java.util.List; -import java.util.Set; import java.util.function.Consumer; import java.util.function.Supplier; @@ -64,7 +63,7 @@ public LockMode getLockMode() { } @Override - public Set getTableGroupJoins() { + public List getTableGroupJoins() { return collectionTableGroup.getTableGroupJoins(); } @@ -73,11 +72,6 @@ public boolean hasTableGroupJoins() { return collectionTableGroup.hasTableGroupJoins(); } - @Override - public void setTableGroupJoins(Set joins) { - collectionTableGroup.setTableGroupJoins( joins ); - } - @Override public void addTableGroupJoin(TableGroupJoin join) { collectionTableGroup.addTableGroupJoin( join ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/ast/CriteriaEntityGraphTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/ast/CriteriaEntityGraphTest.java index 42ac00a7d4..e2bc576071 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/ast/CriteriaEntityGraphTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/ast/CriteriaEntityGraphTest.java @@ -160,7 +160,7 @@ void testFetchSemanticsWithDeepSubgraph() { // Check the from-clause assertEntityValuedJoinedGroup( sqlAst, "owner", Person.class, tableGroup -> { - Set tableGroupJoins = tableGroup.getTableGroupJoins(); + List tableGroupJoins = tableGroup.getTableGroupJoins(); Map> tableGroupByName = tableGroupJoins.stream() .map( TableGroupJoin::getJoinedGroup ) .collect( Collectors.toMap( diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/ast/EntityGraphLoadPlanBuilderTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/ast/EntityGraphLoadPlanBuilderTest.java index 12e56dae92..67d393230c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/ast/EntityGraphLoadPlanBuilderTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/ast/EntityGraphLoadPlanBuilderTest.java @@ -8,6 +8,7 @@ import java.util.Collection; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Consumer; @@ -155,7 +156,7 @@ void testFetchLoadPlanBuildingWithDeepSubgraph() { // Check the from-clause assertEntityValuedJoinedGroup( sqlAst, "owner", Person.class, tableGroup -> { - Set tableGroupJoins = tableGroup.getTableGroupJoins(); + List tableGroupJoins = tableGroup.getTableGroupJoins(); Map> tableGroupByName = tableGroupJoins.stream() .map( TableGroupJoin::getJoinedGroup ) .collect( Collectors.toMap( diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/ast/HqlEntityGraphTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/ast/HqlEntityGraphTest.java index 52d1982796..5c2fde02d2 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/ast/HqlEntityGraphTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/ast/HqlEntityGraphTest.java @@ -8,6 +8,7 @@ import java.util.Collection; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Consumer; @@ -157,7 +158,7 @@ void testFetchSemanticsWithDeepSubgraph() { // Check the from-clause assertEntityValuedJoinedGroup( sqlAst, "owner", Person.class, tableGroup -> { - Set tableGroupJoins = tableGroup.getTableGroupJoins(); + List tableGroupJoins = tableGroup.getTableGroupJoins(); Map> tableGroupByName = tableGroupJoins.stream() .map( TableGroupJoin::getJoinedGroup ) .collect( Collectors.toMap(