diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstTranslator.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstTranslator.java index a49af9e106df..8af30b45edc3 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstTranslator.java @@ -5710,7 +5710,7 @@ protected boolean rendersTableReferenceAlias(Clause clause) { } protected void registerAffectedTable(NamedTableReference tableReference) { - registerAffectedTable( tableReference.getTableExpression() ); + tableReference.applyAffectedTableNames( this::registerAffectedTable ); } protected void registerAffectedTable(String tableExpression) { diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/NamedTableReference.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/NamedTableReference.java index d78c1a3c7e10..a7ac572f5b3f 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/NamedTableReference.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/NamedTableReference.java @@ -12,6 +12,7 @@ import java.util.function.Consumer; import java.util.function.Function; +import org.hibernate.Internal; import org.hibernate.spi.NavigablePath; import org.hibernate.sql.ast.SqlAstWalker; @@ -60,31 +61,26 @@ public void accept(SqlAstWalker sqlTreeWalker) { sqlTreeWalker.visitNamedTableReference( this ); } - @Override - public void applyAffectedTableNames(Consumer nameCollector) { - nameCollector.accept( getTableExpression() ); - } - @Override public List getAffectedTableNames() { - return Collections.singletonList( getTableExpression() ); + return Collections.singletonList( tableExpression ); } @Override public boolean containsAffectedTableName(String requestedName) { - return isEmpty( requestedName ) || getTableExpression().contains( requestedName ); + return isEmpty( requestedName ) || tableExpression.equals( requestedName ); } @Override public Boolean visitAffectedTableNames(Function nameCollector) { - return nameCollector.apply( getTableExpression() ); + return nameCollector.apply( tableExpression ); } @Override public TableReference resolveTableReference( NavigablePath navigablePath, String tableExpression) { - if ( tableExpression.equals( getTableExpression() ) ) { + if ( this.tableExpression.equals( tableExpression ) ) { return this; } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/UnionTableReference.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/UnionTableReference.java index d38bc05f2497..6a84e42d49b8 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/UnionTableReference.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/UnionTableReference.java @@ -67,9 +67,6 @@ public TableReference getTableReference( } private boolean hasTableExpression(String tableExpression) { - if ( tableExpression.equals( getTableExpression() ) ) { - return true; - } for ( String expression : subclassTableSpaceExpressions ) { if ( tableExpression.equals( expression ) ) { return true;