mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-22 19:15:15 +00:00
Fix wrong order in SQL TableGroupJoin rendering
This commit is contained in:
parent
6c3d0d86dc
commit
222e3fb697
@ -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<TableGroupJoin> tableGroupJoins;
|
||||
|
||||
public TableGroupImpl(
|
||||
NavigablePath navigablePath,
|
||||
@ -76,32 +74,22 @@ public LockMode getLockMode() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TableGroupJoin> getTableGroupJoins() {
|
||||
return tableGroupJoins == null ? Collections.emptySet() : tableGroupJoins;
|
||||
public List<TableGroupJoin> getTableGroupJoins() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTableGroupJoins() {
|
||||
return tableGroupJoins != null && ! tableGroupJoins.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTableGroupJoins(Set<TableGroupJoin> joins) {
|
||||
throw new UnsupportedOperationException();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTableGroupJoin(TableGroupJoin join) {
|
||||
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTableGroupJoins(Consumer<TableGroupJoin> consumer) {
|
||||
if ( tableGroupJoins == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
tableGroupJoins.forEach( consumer );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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<TableGroupJoin> tableGroupJoins = tableGroup.getTableGroupJoins();
|
||||
final List<TableGroupJoin> tableGroupJoins = tableGroup.getTableGroupJoins();
|
||||
if ( ! tableGroupJoins.isEmpty() ) {
|
||||
logNode(
|
||||
"TableGroupJoins",
|
||||
|
@ -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<TableGroupJoin> getTableGroupJoins() {
|
||||
return Collections.emptySet();
|
||||
public List<TableGroupJoin> getTableGroupJoins() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -82,10 +81,6 @@ public TableReference resolveTableReference(
|
||||
return cteTableReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTableGroupJoins(Set<TableGroupJoin> joins) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitTableGroupJoins(Consumer<TableGroupJoin> consumer) {
|
||||
}
|
||||
|
@ -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<TableGroupJoin> tableGroupJoins;
|
||||
private List<TableGroupJoin> tableGroupJoins;
|
||||
private boolean isInnerJoinPossible;
|
||||
|
||||
private final SessionFactoryImplementor sessionFactory;
|
||||
@ -93,8 +93,8 @@ protected SessionFactoryImplementor getSessionFactory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TableGroupJoin> getTableGroupJoins() {
|
||||
return tableGroupJoins == null ? Collections.emptySet() : Collections.unmodifiableSet( tableGroupJoins );
|
||||
public List<TableGroupJoin> 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<TableGroupJoin> 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
|
||||
|
@ -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<TableGroupJoin> tableGroupJoins;
|
||||
private List<TableGroupJoin> tableGroupJoins;
|
||||
|
||||
public CompositeTableGroup(
|
||||
NavigablePath navigablePath,
|
||||
@ -64,8 +63,8 @@ public LockMode getLockMode() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TableGroupJoin> getTableGroupJoins() {
|
||||
return tableGroupJoins == null ? Collections.emptySet() : Collections.unmodifiableSet( tableGroupJoins );
|
||||
public List<TableGroupJoin> 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<TableGroupJoin> 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
|
||||
|
@ -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<TableGroupJoin> getTableGroupJoins() {
|
||||
return Collections.emptySet();
|
||||
public List<TableGroupJoin> getTableGroupJoins() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -99,11 +98,6 @@ public boolean hasTableGroupJoins() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTableGroupJoins(Set<TableGroupJoin> joins) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTableGroupJoin(TableGroupJoin join) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
@ -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<TableGroupJoin> getTableGroupJoins();
|
||||
List<TableGroupJoin> getTableGroupJoins();
|
||||
|
||||
boolean hasTableGroupJoins();
|
||||
|
||||
void setTableGroupJoins(Set<TableGroupJoin> joins);
|
||||
|
||||
void addTableGroupJoin(TableGroupJoin join);
|
||||
|
||||
void visitTableGroupJoins(Consumer<TableGroupJoin> consumer);
|
||||
|
@ -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<TableGroupJoin> tableGroupJoins;
|
||||
private List<TableGroupJoin> tableGroupJoins;
|
||||
|
||||
private final UnionSubclassEntityPersister modelPart;
|
||||
private final TableReference tableReference;
|
||||
@ -64,8 +63,8 @@ public LockMode getLockMode() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TableGroupJoin> getTableGroupJoins() {
|
||||
return tableGroupJoins == null ? Collections.emptySet() : Collections.unmodifiableSet( tableGroupJoins );
|
||||
public List<TableGroupJoin> 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<TableGroupJoin> 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
|
||||
|
@ -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<TableGroupJoin> getTableGroupJoins() {
|
||||
public List<TableGroupJoin> getTableGroupJoins() {
|
||||
return collectionTableGroup.getTableGroupJoins();
|
||||
}
|
||||
|
||||
@ -73,11 +72,6 @@ public boolean hasTableGroupJoins() {
|
||||
return collectionTableGroup.hasTableGroupJoins();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTableGroupJoins(Set<TableGroupJoin> joins) {
|
||||
collectionTableGroup.setTableGroupJoins( joins );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTableGroupJoin(TableGroupJoin join) {
|
||||
collectionTableGroup.addTableGroupJoin( join );
|
||||
|
@ -160,7 +160,7 @@ void testFetchSemanticsWithDeepSubgraph() {
|
||||
|
||||
// Check the from-clause
|
||||
assertEntityValuedJoinedGroup( sqlAst, "owner", Person.class, tableGroup -> {
|
||||
Set<TableGroupJoin> tableGroupJoins = tableGroup.getTableGroupJoins();
|
||||
List<TableGroupJoin> tableGroupJoins = tableGroup.getTableGroupJoins();
|
||||
Map<String, Class<? extends TableGroup>> tableGroupByName = tableGroupJoins.stream()
|
||||
.map( TableGroupJoin::getJoinedGroup )
|
||||
.collect( Collectors.toMap(
|
||||
|
@ -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<TableGroupJoin> tableGroupJoins = tableGroup.getTableGroupJoins();
|
||||
List<TableGroupJoin> tableGroupJoins = tableGroup.getTableGroupJoins();
|
||||
Map<String, Class<? extends TableGroup>> tableGroupByName = tableGroupJoins.stream()
|
||||
.map( TableGroupJoin::getJoinedGroup )
|
||||
.collect( Collectors.toMap(
|
||||
|
@ -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<TableGroupJoin> tableGroupJoins = tableGroup.getTableGroupJoins();
|
||||
List<TableGroupJoin> tableGroupJoins = tableGroup.getTableGroupJoins();
|
||||
Map<String, Class<? extends TableGroup>> tableGroupByName = tableGroupJoins.stream()
|
||||
.map( TableGroupJoin::getJoinedGroup )
|
||||
.collect( Collectors.toMap(
|
||||
|
Loading…
x
Reference in New Issue
Block a user