hibernate/hibernate-orm · error · SemanticException
Non-boolean expression used in predicate context
Error message
Non-boolean expression used in predicate context: {} What it means
Thrown by SemanticQueryBuilder.visitBooleanExpressionPredicate when an expression used directly in predicate position (where/having, without a comparison operator) does not have a boolean type. HQL requires a boolean expression where a predicate is expected; the offending input is the non-boolean expression, whose type is reported.
Solutions
- Wrap the expression in a comparison so it yields a boolean.
- Use the expression in a value context instead of a predicate context.
Defensive patterns
Strategy: validation
When it happens
Trigger: A path expression of the wrong type is used in a collection predicate.
Common situations: Applying member of / is empty / includes / intersects / in-array to non-plural expressions.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/e7389db3e1c1e1b3.
Report an issue: GitHub.
Appendix: source
Thrown at hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java:3477
}
@Override
public SqmPredicate visitExistsCollectionPartPredicate(HqlParser.ExistsCollectionPartPredicateContext ctx) {
final var subQuery = createCollectionReferenceSubQuery( ctx.simplePath(), null );
return new SqmExistsPredicate( subQuery, nodeBuilder() );
}
@Override
public SqmPredicate visitExistsPredicate(HqlParser.ExistsPredicateContext ctx) {
final var expression = (SqmExpression<?>) ctx.expression().accept( this );
return new SqmExistsPredicate( expression, nodeBuilder() );
}
@Override
public SqmPredicate visitBooleanExpressionPredicate(HqlParser.BooleanExpressionPredicateContext ctx) {
final var expression = (SqmExpression<?>) ctx.expression().accept( this );
if ( resolveExpressibleJavaTypeClass( expression ) != Boolean.class ) {
throw new SemanticException(
"Non-boolean expression used in predicate context: " + ctx.getText(),
query
);
}
@SuppressWarnings("unchecked")
final var booleanExpression = (SqmExpression<Boolean>) expression;
return new SqmBooleanExpressionPredicate( booleanExpression, nodeBuilder() );
}
@Override
public Object visitEntityTypeExpression(HqlParser.EntityTypeExpressionContext ctx) {
final var entityTypeReferenceContext = ctx.entityTypeReference();
// can be one of 2 forms:
// 1) TYPE( some.path )
// 2) TYPE( :someParam )
final var parameter = entityTypeReferenceContext.parameter();
final var path = entityTypeReferenceContext.path();
if ( parameter != null ) {View on GitHub (pinned to fad1729dce)