Skip to content

Commit

Permalink
HHH-16792 Unqualify table expressions for cte table names
Browse files Browse the repository at this point in the history
  • Loading branch information
mbladel committed Jun 30, 2023
1 parent 520394a commit 63cccf8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Expand Up @@ -11,6 +11,7 @@
import java.util.Map;

import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.relational.QualifiedNameParser;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.mapping.EntityMappingType;
Expand Down Expand Up @@ -183,7 +184,7 @@ protected void addDmlCtes(
protected String getCteTableName(String tableExpression) {
final Dialect dialect = getSessionFactory().getJdbcServices().getDialect();
if ( Identifier.isQuoted( tableExpression ) ) {
tableExpression = tableExpression.substring( 1, tableExpression.length() - 1 );
tableExpression = QualifiedNameParser.INSTANCE.parse( tableExpression ).getObjectName().getText();
}
return Identifier.toIdentifier( DELETE_RESULT_TABLE_NAME_PREFIX + tableExpression ).render( dialect );
}
Expand Down
Expand Up @@ -12,6 +12,7 @@
import java.util.function.BiConsumer;

import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.relational.QualifiedNameParser;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.util.collections.CollectionHelper;
Expand Down Expand Up @@ -324,7 +325,7 @@ private TableReference resolveTableReference(
protected String getCteTableName(String tableExpression) {
final Dialect dialect = getSessionFactory().getJdbcServices().getDialect();
if ( Identifier.isQuoted( tableExpression ) ) {
tableExpression = tableExpression.substring( 1, tableExpression.length() - 1 );
tableExpression = QualifiedNameParser.INSTANCE.parse( tableExpression ).getObjectName().getText();
}
return Identifier.toIdentifier( UPDATE_RESULT_TABLE_NAME_PREFIX + tableExpression ).render( dialect );
}
Expand Down

0 comments on commit 63cccf8

Please sign in to comment.