HHH-17686 Avoid internal use of pruned expression for named references

This commit is contained in:
Marco Belladelli 2024-01-30 09:39:37 +01:00 committed by Christian Beikov
parent 26a8c28e9d
commit 2c86dcd5be
3 changed files with 6 additions and 13 deletions

View File

@ -6314,7 +6314,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
}
protected void registerAffectedTable(NamedTableReference tableReference) {
registerAffectedTable( tableReference.getTableExpression() );
tableReference.applyAffectedTableNames( this::registerAffectedTable );
}
protected void registerAffectedTable(String tableExpression) {

View File

@ -12,6 +12,7 @@ import java.util.Locale;
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 class NamedTableReference extends AbstractTableReference {
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;
}

View File

@ -67,9 +67,6 @@ public class UnionTableReference extends NamedTableReference {
}
private boolean hasTableExpression(String tableExpression) {
if ( tableExpression.equals( getTableExpression() ) ) {
return true;
}
for ( String expression : subclassTableSpaceExpressions ) {
if ( tableExpression.equals( expression ) ) {
return true;