{"record":{"id":"2a259251667379a4","repo":"hibernate/hibernate-orm","slug":"could-not-resolve-treat-target-type-treattarg","errorCode":null,"errorMessage":"Could not resolve treat target type '\" + treatTargetName + \"'","messagePattern":"Could not resolve treat target type '\" \\+ treatTargetName \\+ \"'","errorType":"exception","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java","lineNumber":5931,"sourceCode":"\t@Override\n\tpublic SqmPath<?> visitTreatedNavigablePath(HqlParser.TreatedNavigablePathContext ctx) {\n\t\tfinal var consumer = dotIdentifierConsumerStack.getCurrent();\n\t\tfinal boolean madeNested;\n\t\tif ( consumer instanceof QualifiedJoinPathConsumer qualifiedJoinPathConsumer ) {\n\t\t\tmadeNested = !qualifiedJoinPathConsumer.isNested();\n\t\t\tif ( madeNested ) {\n\t\t\t\tqualifiedJoinPathConsumer.setNested( true );\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tmadeNested = false;\n\t\t}\n\t\tconsumeManagedTypeReference( ctx.path() );\n\n\t\tfinal String treatTargetName = ctx.simplePath().getText();\n\t\tfinal String importableName = getJpaMetamodel().qualifyImportableName( treatTargetName );\n\t\tif ( importableName == null ) {\n\t\t\tthrow new SemanticException( \"Could not resolve treat target type '\" + treatTargetName + \"'\", query );\n\t\t}\n\n\t\tfinal boolean hasContinuation = ctx.getChildCount() == 7;\n\t\tconsumer.consumeTreat( importableName, !hasContinuation );\n\t\tSqmPath<?> result = (SqmPath<?>) consumer.getConsumedPart();\n\n\t\tif ( hasContinuation ) {\n\t\t\tif ( madeNested ) {\n\t\t\t\t// Reset the nested state before consuming the terminal identifier\n\t\t\t\t( (QualifiedJoinPathConsumer) consumer ).setNested( false );\n\t\t\t}\n\t\t\tfinal boolean addConsumer = !( consumer instanceof QualifiedJoinPathConsumer );\n\t\t\tif ( addConsumer ) {\n\t\t\t\tdotIdentifierConsumerStack.push(\n\t\t\t\t\t\tnew BasicDotIdentifierConsumer( result, this ) {\n\t\t\t\t\t\t\t@Override\n\t\t\t\t\t\t\tprotected void reset() {\n\t\t\t\t\t\t\t}","sourceCodeStart":5913,"sourceCodeEnd":5949,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java#L5913-L5949","documentation":"Error \"Could not resolve treat target type '\" + treatTargetName + \"'\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A name/path expected to denote an entity type does not: Could not resolve treat target type '\" + treatTargetName + \"'","commonSituations":"Passing non-entity arguments to version()/naturalid(), or a TREAT target / entity name that is not a mapped entity; commonly a typo or unmapped class.","solutions":["The TREAT target type name could not be resolved. Use the entity name (or imported FQN) of a mapped subtype in treat(x as Type)."],"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"}