{"record":{"id":"19c79b0b35c07e06","repo":"hibernate/hibernate-orm","slug":"first-operand-for-contains-predicate-must-be-a-bas","errorCode":null,"errorMessage":"First operand for contains predicate must be a basic plural type expression, but found: {}","messagePattern":"First operand for contains predicate must be a basic plural type expression, but found: (.+?)","errorType":"exception","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java","lineNumber":2562,"sourceCode":"\t\tif ( firstSymbol.getType() == HqlParser.NOT ) {\n\t\t\tnegated = true;\n\t\t\toperationSymbol = ((TerminalNode) ctx.getChild( 2 )).getSymbol();\n\t\t}\n\t\telse {\n\t\t\tnegated = firstSymbol.getType() == HqlParser.IS\n\t\t\t\t\t&& ((TerminalNode) ctx.getChild( 2 )).getSymbol().getType() == HqlParser.NOT;\n\t\t\toperationSymbol = firstSymbol;\n\t\t}\n\t\tfinal var expressions = ctx.expression();\n\t\tfinal var lhsCtx = expressions.get( 0 );\n\t\tfinal var rhsCtx = expressions.get( 1 );\n\t\treturn switch ( operationSymbol.getType() ) {\n\t\t\tcase HqlParser.CONTAINS -> {\n\t\t\t\tfinal var lhs = (SqmExpression<?>) lhsCtx.accept( this );\n\t\t\t\tfinal var rhs = (SqmExpression<?>) rhsCtx.accept( this );\n\t\t\t\tfinal var lhsExpressible = lhs.getExpressible();\n\t\t\t\tif ( lhsExpressible != null && !(lhsExpressible.getSqmType() instanceof BasicPluralType<?, ?>) ) {\n\t\t\t\t\tthrow new SemanticException(\n\t\t\t\t\t\t\t\"First operand for contains predicate must be a basic plural type expression, but found: \" + lhsExpressible.getSqmType(),\n\t\t\t\t\t\t\tquery\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tfinal SelfRenderingSqmFunction<Boolean> contains = getFunctionDescriptor(\n\t\t\t\t\t\t\"array_contains\" ).generateSqmExpression(\n\t\t\t\t\t\tasList( lhs, rhs ),\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\tqueryEngine()\n\t\t\t\t);\n\t\t\t\tyield new SqmBooleanExpressionPredicate( contains, negated, nodeBuilder() );\n\t\t\t}\n\t\t\tcase HqlParser.INCLUDES -> {\n\t\t\t\tfinal var lhs = (SqmExpression<?>) lhsCtx.accept( this );\n\t\t\t\tfinal var rhs = (SqmExpression<?>) rhsCtx.accept( this );\n\t\t\t\tfinal var lhsExpressible = lhs.getExpressible();\n\t\t\t\tfinal var rhsExpressible = rhs.getExpressible();\n\t\t\t\tif ( lhsExpressible != null && !( lhsExpressible.getSqmType() instanceof BasicPluralType<?, ?>) ) {","sourceCodeStart":2544,"sourceCodeEnd":2580,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java#L2544-L2580","documentation":"Error \"First operand for contains predicate must be a basic plural type expression, but found: {}\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A path expression of the wrong type is used in a collection predicate.","commonSituations":"Applying member of / is empty / includes / intersects / in-array to non-plural expressions.","solutions":["Use a basic plural (array/collection of basic values) expression as the first operand of 'contains'.","Verify the operand type is an array or basic collection."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}