diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlExpressionResolver.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlExpressionResolver.java index 9bd17b3104..41c4f54689 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlExpressionResolver.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlExpressionResolver.java @@ -8,11 +8,14 @@ package org.hibernate.sql.ast.spi; import java.util.function.Function; +import org.hibernate.metamodel.mapping.SelectableMapping; import org.hibernate.sql.ast.tree.expression.Expression; import org.hibernate.sql.ast.tree.from.TableReference; import org.hibernate.type.descriptor.java.JavaType; import org.hibernate.type.spi.TypeConfiguration; +import static java.util.Locale.ROOT; + /** * Resolution of a SqlSelection reference for a given SqlSelectable. Some * SqlSelectable are required to be qualified (e.g. a Column) - this is indicated @@ -54,6 +57,15 @@ public interface SqlExpressionResolver { return qualifier + columnExpression; } + /** + * Convenience form for creating a key from TableReference and SelectableMapping + */ + static String createColumnReferenceKey(TableReference tableReference, SelectableMapping selectable) { + assert selectable.getContainingTableExpression().equals( tableReference.getTableExpression() ) + : String.format( ROOT, "Expecting tables to match between TableReference (%s) and SelectableMapping (%s)", tableReference.getTableExpression(), selectable.getContainingTableExpression() ); + return createColumnReferenceKey( tableReference, selectable.getSelectionExpression() ); + } + /** * Given a qualifier + a qualifiable SqlExpressable, resolve the * (Sql)Expression reference.