diff --git a/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java index 87b104a198..ed98679bae 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java @@ -2381,7 +2381,7 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implem public SqmNullnessPredicate visitIsNullPredicate(HqlParser.IsNullPredicateContext ctx) { final boolean negated = ctx.getChildCount() == 4; return new SqmNullnessPredicate( - (SqmExpression) ctx.getChild( 0 ).accept( this ), + (SqmExpression) ctx.expression().accept( this ), negated, creationContext.getNodeBuilder() ); @@ -2390,11 +2390,17 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implem @Override public SqmEmptinessPredicate visitIsEmptyPredicate(HqlParser.IsEmptyPredicateContext ctx) { final boolean negated = ctx.getChildCount() == 4; - return new SqmEmptinessPredicate( - (SqmPluralValuedSimplePath) ctx.getChild( 0 ).accept( this ), - negated, - creationContext.getNodeBuilder() - ); + SqmExpression expression = (SqmExpression) ctx.expression().accept(this); + if ( expression instanceof SqmPluralValuedSimplePath ) { + return new SqmEmptinessPredicate( + (SqmPluralValuedSimplePath) expression, + negated, + creationContext.getNodeBuilder() + ); + } + else { + throw new SemanticException( "Path argument to 'is empty' operator must be a plural attribute" ); + } } @Override @@ -2624,7 +2630,7 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implem ); } else { - throw new SemanticException( "Path argument to MEMBER OF must be a plural attribute" ); + throw new SemanticException( "Path argument to 'member of' operator must be a plural attribute" ); } }