hibernate/hibernate-orm · error · SemanticException

Operand of 'member of' operator must be a plural path

Error message

Operand of 'member of' operator must be a plural path

What it means

Error "Operand of 'member of' operator must be a plural path" thrown in hibernate/hibernate-orm.

Source

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

			}
			return new SqmLiteral<>( escape.charAt( 0 ), characterType, nodeBuilder() );
		}
	}

	@Override
	public SqmPredicate visitMemberOfPredicate(HqlParser.MemberOfPredicateContext ctx) {
		final boolean negated = ctx.NOT() != null;
		if ( consumeDomainPath( ctx.path() )
				instanceof SqmPluralValuedSimplePath<?> pluralValuedSimplePath ) {
			return new SqmMemberOfPredicate(
					(SqmExpression<?>) ctx.expression().accept( this ),
					pluralValuedSimplePath,
					negated,
					nodeBuilder()
			);
		}
		else {
			throw new SemanticException( "Operand of 'member of' operator must be a plural path", query );
		}
	}

	@Override
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public SqmPredicate visitInPredicate(HqlParser.InPredicateContext ctx) {
		final boolean negated = ctx.getChildCount() == 4;
		final var testExpression = (SqmExpression<?>) ctx.expression().accept( this );
		final var inListContext = ctx.inList();
		if ( inListContext instanceof HqlParser.ExplicitTupleInListContext tupleExpressionListContext ) {
			final int size = tupleExpressionListContext.getChildCount();
			final int estimatedSize = size >> 1;
			final String testExpressionJavaType = testExpression.getJavaTypeName();
			final boolean isEnum = testExpression.isEnum();
			// Multivalued bindings are only allowed if there is a single list item, hence size 3 (LP, RP and param)
			parameterDeclarationContextStack.push( () -> size == 3 );
			try {
				final List<SqmExpression<?>> listExpressions = new ArrayList<>( estimatedSize );

View on GitHub (pinned to fad1729dce)

Solutions

  1. Apply 'member of' only to collection-valued paths.
  2. Check that the path is a mapped collection attribute.

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