{"record":{"id":"a9bf0b3c58ae1c5f","repo":"hibernate/hibernate-orm","slug":"slice-operator-applied-to-expression-which-is-not","errorCode":null,"errorMessage":"Slice operator applied to expression which is not a string or SQL array","messagePattern":"Slice operator applied to expression which is not a string or SQL array","errorType":"exception","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java","lineNumber":5822,"sourceCode":"\t\t\t\t\t\t\t\t\t\t\t\tBinaryArithmeticOperator.SUBTRACT,\n\t\t\t\t\t\t\t\t\t\t\t\tend,\n\t\t\t\t\t\t\t\t\t\t\t\tstart,\n\t\t\t\t\t\t\t\t\t\t\t\tnodeBuilder()\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tnew SqmLiteral<>(\n\t\t\t\t\t\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t\t\t\t\t\tnodeBuilder().getIntegerType(),\n\t\t\t\t\t\t\t\t\t\t\t\tnodeBuilder()\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\tnodeBuilder()\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t),\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\tqueryEngine()\n\t\t\t\t);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new SemanticException( \"Slice operator applied to expression which is not a string or SQL array\", query );\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tthrow new ParsingException( \"Illegal domain path '\" + ctx.getText() + \"'\" );\n\t\t}\n\t}\n\n\tprivate SemanticPathPart visitIndexedPathAccessFragment(\n\t\t\tSemanticPathPart pathPart,\n\t\t\tHqlParser.IndexedPathAccessFragmentContext idxCtx) {\n\t\tif ( idxCtx == null ) {\n\t\t\treturn pathPart;\n\t\t}\n\n\t\tfinal var indexExpression = (SqmExpression<?>) idxCtx.expression().accept(this );\n\t\tfinal boolean hasIndexContinuation = idxCtx.DOT() != null;\n\t\tfinal var indexedPath =\n\t\t\t\tpathPart.resolveIndexedAccess( indexExpression, !hasIndexContinuation, this );","sourceCodeStart":5804,"sourceCodeEnd":5840,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java#L5804-L5840","documentation":"Error \"Slice operator applied to expression which is not a string or SQL array\" thrown in hibernate/hibernate-orm.","triggerScenarios":"The slice operator is applied to an unsupported expression: Slice operator applied to expression which is not a string or SQL array","commonSituations":"Using array/string slicing on expressions whose type is unknown or neither string nor SQL array.","solutions":["The slice operator only works on strings and SQL arrays. Apply it to a string or array expression."],"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"}