From f310338198e473d17573481a1d4cbc03620d9336 Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Thu, 11 May 2023 14:42:26 +0200 Subject: [PATCH] HHH-16576 Fix column aliases when rendering query part with table reference aliasing emulation --- .../org/hibernate/sql/ast/spi/AbstractSqlAstTranslator.java | 3 ++- .../java/org/hibernate/orm/test/query/hql/FunctionTests.java | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) 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 5161de950f..c111f1f77e 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 @@ -2866,7 +2866,8 @@ public abstract class AbstractSqlAstTranslator implemen if ( currentQueryPart != null && queryPartForRowNumberingClauseDepth != clauseStack.depth() ) { this.queryPartForRowNumbering = null; this.queryPartForRowNumberingClauseDepth = -1; - this.needsSelectAliases = false; + // If explicit column aliases were defined we should still use them when rendering the select clause + this.needsSelectAliases = columnAliases != null; } // If we are row numbering the current query group, this means that we can't render the // order by and offset fetch clause, so we must do row counting on the query group level diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java index ff35ef52db..fbbbc43b22 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java @@ -1892,9 +1892,6 @@ public class FunctionTests { } @Test - @SkipForDialect(dialectClass = OracleDialect.class, reason = "HHH-16576") - @SkipForDialect(dialectClass = MariaDBDialect.class, reason = "HHH-16576") - @SkipForDialect(dialectClass = MySQLDialect.class, majorVersion = 5, reason = "HHH-16576") public void testMaxOverUnion(SessionFactoryScope scope) { scope.inTransaction( session -> {