diff --git a/hibernate-core/src/main/antlr/org/hibernate/grammars/hql/HqlParser.g4 b/hibernate-core/src/main/antlr/org/hibernate/grammars/hql/HqlParser.g4 index ccfbb2a51e..4b4aaa6053 100644 --- a/hibernate-core/src/main/antlr/org/hibernate/grammars/hql/HqlParser.g4 +++ b/hibernate-core/src/main/antlr/org/hibernate/grammars/hql/HqlParser.g4 @@ -710,11 +710,13 @@ countFunction ; everyFunction - : (EVERY|ALL) LEFT_PAREN (predicate | subQuery) RIGHT_PAREN filterClause? + : (EVERY|ALL) LEFT_PAREN predicate RIGHT_PAREN filterClause? + | (EVERY|ALL) LEFT_PAREN subQuery RIGHT_PAREN ; anyFunction - : (ANY|SOME) LEFT_PAREN (predicate | subQuery) RIGHT_PAREN filterClause? + : (ANY|SOME) LEFT_PAREN predicate RIGHT_PAREN filterClause? + | (ANY|SOME) LEFT_PAREN subQuery RIGHT_PAREN ; filterClause diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/AggregateFilterClauseTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/AggregateFilterClauseTest.java index c981d741f0..0c6a38e994 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/AggregateFilterClauseTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/AggregateFilterClauseTest.java @@ -10,6 +10,7 @@ import java.util.Date; import org.hibernate.query.Query; import org.hibernate.query.SemanticException; +import org.hibernate.query.sqm.ParsingException; import org.hibernate.testing.orm.domain.StandardDomainModel; import org.hibernate.testing.orm.domain.gambit.EntityOfBasics; @@ -245,11 +246,11 @@ public class AggregateFilterClauseTest { Exception e = Assertions.assertThrows( IllegalArgumentException.class, () -> { - session.createQuery( "select every( eob.theInteger > 0 ) filter ( where select 1 ) from EntityOfBasics eob" ); + session.createQuery( "select every( select 1 ) filter ( where eob.theBoolean = false ) from EntityOfBasics eob" ); } ); - assertEquals( SemanticException.class, e.getCause().getClass() ); + assertEquals( ParsingException.class, e.getCause().getClass() ); } ); scope.inTransaction( @@ -257,11 +258,11 @@ public class AggregateFilterClauseTest { Exception e = Assertions.assertThrows( IllegalArgumentException.class, () -> { - session.createQuery( "select any( eob.theInteger > 0 ) filter ( where select 1 ) from EntityOfBasics eob" ); + session.createQuery( "select any( select 1 ) filter ( where eob.theBoolean = false ) from EntityOfBasics eob" ); } ); - assertEquals( SemanticException.class, e.getCause().getClass() ); + assertEquals( ParsingException.class, e.getCause().getClass() ); } ); }