Skip to content

Commit

Permalink
HHH-17686 Avoid internal use of pruned expression for named references
Browse files Browse the repository at this point in the history
  • Loading branch information
mbladel authored and beikov committed Jan 31, 2024
1 parent 702caf4 commit 24d25ce
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -60,31 +61,26 @@ public void accept(SqlAstWalker sqlTreeWalker) {
sqlTreeWalker.visitNamedTableReference( this );
}

@Override
public void applyAffectedTableNames(Consumer<String> nameCollector) {
nameCollector.accept( getTableExpression() );
}

@Override
public List<String> 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<String, Boolean> 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 24d25ce

Please sign in to comment.