From ac8b2a02b1ecab725377a4e28dd6f4c4391248c7 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 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 3bd9f0e348..c4d71908de 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 @@ -2865,7 +2865,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