From 9e09c057c5f387da96e71b6573f8e8b7d3bdaa0f Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Mon, 8 May 2023 11:12:32 +0200 Subject: [PATCH] HHH-16495 SemanticException for non-cross entity joins without predicate --- .../hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java index 6efc1f93ae..7f5bf684ee 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java @@ -3403,13 +3403,18 @@ public abstract class BaseSqmToSqlAstConverter extends Base predicate.get() ); - // add any additional join restrictions if ( sqmJoin.getJoinPredicate() != null ) { final SqmJoin oldJoin = currentlyProcessingJoin; currentlyProcessingJoin = sqmJoin; tableGroupJoin.applyPredicate( visitNestedTopLevelPredicate( sqmJoin.getJoinPredicate() ) ); currentlyProcessingJoin = oldJoin; } + else if ( correspondingSqlJoinType != SqlAstJoinType.CROSS ) { + throw new SemanticException( + "Entity join did not specify a predicate, " + + "please define an on clause or use an explicit cross join: " + sqmJoin + ); + } // Note that we add the entity join after processing the predicate because implicit joins needed in there // can be just ordered right before the entity join without changing the semantics