{"record":{"id":"3d5a2ee0730fe4f5","repo":"hibernate/hibernate-orm","slug":"slice-operator-applied-to-expression-of-unknown-ty","errorCode":null,"errorMessage":"Slice operator applied to expression of unknown type","messagePattern":"Slice operator applied to expression of unknown type","errorType":"exception","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java","lineNumber":5780,"sourceCode":"\tpublic SemanticPathPart visitSyntacticDomainPath(HqlParser.SyntacticDomainPathContext ctx) {\n\t\tif ( ctx.treatedNavigablePath() != null ) {\n\t\t\treturn visitTreatedNavigablePath( ctx.treatedNavigablePath() );\n\t\t}\n\t\telse if ( ctx.collectionValueNavigablePath() != null ) {\n\t\t\treturn visitCollectionValueNavigablePath( ctx.collectionValueNavigablePath() );\n\t\t}\n\t\telse if ( ctx.mapKeyNavigablePath() != null ) {\n\t\t\treturn visitMapKeyNavigablePath( ctx.mapKeyNavigablePath() );\n\t\t}\n\t\telse if ( ctx.simplePath() != null && ctx.indexedPathAccessFragment() != null ) {\n\t\t\treturn visitIndexedPathAccessFragment( visitSimplePath( ctx.simplePath() ), ctx.indexedPathAccessFragment() );\n\t\t}\n\t\telse if ( ctx.simplePath() != null && ctx.slicedPathAccessFragment() != null ) {\n\t\t\tfinal var slicedFragments = ctx.slicedPathAccessFragment().expression();\n\t\t\tfinal var lhs = (SqmTypedNode<?>) visitSimplePath( ctx.simplePath() );\n\t\t\tfinal var lhsExpressible = lhs.getExpressible();\n\t\t\tif ( lhsExpressible == null ) {\n\t\t\t\tthrow new SemanticException( \"Slice operator applied to expression of unknown type\", query );\n\t\t\t}\n\t\t\telse if ( lhsExpressible.getSqmType() instanceof BasicPluralType<?, ?> ) {\n\t\t\t\treturn getFunctionDescriptor( \"array_slice\" ).generateSqmExpression(\n\t\t\t\t\t\tList.of(\n\t\t\t\t\t\t\t\tlhs,\n\t\t\t\t\t\t\t\t(SqmTypedNode<?>) slicedFragments.get( 0 ).accept( this ),\n\t\t\t\t\t\t\t\t(SqmTypedNode<?>) slicedFragments.get( 1 ).accept( this )\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 if ( lhsExpressible.getRelationalJavaType() instanceof StringJavaType\n\t\t\t\t\t&& !(lhs instanceof SqmPluralValuedSimplePath) ) {\n\t\t\t\tfinal var start = (SqmExpression<?>) slicedFragments.get( 0 ).accept( this );\n\t\t\t\tfinal var end = (SqmExpression<?>) slicedFragments.get( 1 ).accept( this );\n\t\t\t\treturn getFunctionDescriptor( \"substring\" ).generateSqmExpression(\n\t\t\t\t\t\tList.of(","sourceCodeStart":5762,"sourceCodeEnd":5798,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java#L5762-L5798","documentation":"Error \"Slice operator applied to expression of unknown type\" thrown in hibernate/hibernate-orm.","triggerScenarios":"The slice operator is applied to an unsupported expression: Slice operator applied to expression of unknown type","commonSituations":"Using array/string slicing on expressions whose type is unknown or neither string nor SQL array.","solutions":["The slice operator was applied to an expression whose type cannot be determined. Give the expression a resolvable type (e.g. cast it or reference a typed path) before slicing."],"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"}