hibernate/hibernate-orm · error · SemanticException

Second operand for includes predicate must be a basic plural

Error message

Second operand for includes predicate must be a basic plural type expression, but found: {}

What it means

Error "Second operand for includes predicate must be a basic plural type expression, but found: {}" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java:2588

						null,
						queryEngine()
				);
				yield new SqmBooleanExpressionPredicate( contains, negated, nodeBuilder() );
			}
			case HqlParser.INCLUDES -> {
				final var lhs = (SqmExpression<?>) lhsCtx.accept( this );
				final var rhs = (SqmExpression<?>) rhsCtx.accept( this );
				final var lhsExpressible = lhs.getExpressible();
				final var rhsExpressible = rhs.getExpressible();
				if ( lhsExpressible != null && !( lhsExpressible.getSqmType() instanceof BasicPluralType<?, ?>) ) {
					throw new SemanticException(
							"First operand for includes predicate must be a basic plural type expression, but found: "
							+ lhsExpressible.getSqmType(),
							query
					);
				}
				if ( rhsExpressible != null && !( rhsExpressible.getSqmType() instanceof BasicPluralType<?, ?>) ) {
					throw new SemanticException(
							"Second operand for includes predicate must be a basic plural type expression, but found: "
							+ rhsExpressible.getSqmType(),
							query
					);
				}
				final SelfRenderingSqmFunction<Boolean> contains = getFunctionDescriptor( "array_includes" ).generateSqmExpression(
						asList( lhs, rhs ),
						null,
						queryEngine()
				);
				yield new SqmBooleanExpressionPredicate( contains, negated, nodeBuilder() );
			}
			case HqlParser.INTERSECTS -> {
				final var lhs = (SqmExpression<?>) lhsCtx.accept( this );
				final var rhs = (SqmExpression<?>) rhsCtx.accept( this );
				final var lhsExpressible = lhs.getExpressible();
				if ( lhsExpressible != null && !( lhsExpressible.getSqmType() instanceof BasicPluralType<?, ?>) ) {
					throw new SemanticException(

View on GitHub (pinned to fad1729dce)

Solutions

  1. Use a basic plural expression as the second operand of 'includes'.
  2. Verify the operand is an array/collection of basic type.

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/06b3954f5aafecdd. Report an issue: GitHub.