hibernate/hibernate-orm · error · SemanticException

Right operand for in-array predicate must be a basic plural

Error message

Right operand for in-array predicate must be a basic plural type expression, but found: {}

What it means

Error "Right operand for in-array 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:3440

					testExpression,
					createCollectionReferenceSubQuery(
							collectionReferenceInListContext.simplePath(),
							(TerminalNode) collectionReferenceInListContext.collectionQuantifier().getChild(0).getChild(0)
					),
					negated,
					nodeBuilder()
			);
		}
		else if ( inListContext instanceof HqlParser.ArrayInListContext arrayInListContext ) {
			if ( getCreationOptions().useStrictJpaCompliance() ) {
				throw new StrictJpaComplianceViolation( StrictJpaComplianceViolation.Type.HQL_COLLECTION_FUNCTION );
			}

			final var arrayExpr = (SqmExpression<?>) arrayInListContext.expression().accept( this );
			final var arrayExpressible = arrayExpr.getExpressible();
			if ( arrayExpressible != null ) {
				if ( !(arrayExpressible.getSqmType() instanceof BasicPluralType<?, ?> pluralType) ) {
					throw new SemanticException(
							"Right operand for in-array predicate must be a basic plural type expression, but found: "
								+ arrayExpressible.getSqmType(),
							query
					);
				}
				testExpression.applyInferableType( pluralType.getElementType() );
			}
			final SelfRenderingSqmFunction<Boolean> contains = getFunctionDescriptor( "array_contains" ).generateSqmExpression(
					asList( arrayExpr, testExpression ),
					null,
					queryEngine()
			);
			return new SqmBooleanExpressionPredicate( contains, negated, nodeBuilder() );
		}
		else {
			throw new ParsingException( "Unexpected IN predicate type [" + ctx.getClass().getSimpleName() + "] : "
					+ ctx.getText() );
		}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Use a basic plural expression as the right operand of the in-array predicate.
  2. Pass an array/collection parameter 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/d02516a852e3e035. Report an issue: GitHub.