HHH-16792 Unqualify table expressions for cte table names

This commit is contained in:
Marco Belladelli 2023-06-19 11:10:27 +02:00
parent 520394a790
commit 63cccf87dc
2 changed files with 4 additions and 2 deletions

View File

@ -11,6 +11,7 @@ import java.util.List;
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;
@ -183,7 +184,7 @@ public class CteDeleteHandler extends AbstractCteMutationHandler implements Dele
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 );
}

View File

@ -12,6 +12,7 @@ import java.util.Map;
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;
@ -324,7 +325,7 @@ public class CteUpdateHandler extends AbstractCteMutationHandler implements Upda
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 );
}