{"record":{"id":"da272cd30653cf35","repo":"hibernate/hibernate-orm","slug":"named-subgraph-type-type-is-not-a-subtype-of-da272c","errorCode":null,"errorMessage":"Named subgraph type '${type}' is not a subtype of the key type '${keyType}'","messagePattern":"Named subgraph type '(.+?)' is not a subtype of the key type '(.+?)'","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/NamedGraphCreatorJpa.java","lineNumber":388,"sourceCode":"\t\t\tAttributeNodeImplementor<T, E, K> attributeNode, Class<?> subgraphType) {\n\t\tfinal var attributeValueType =\n\t\t\t\tattributeNode.getAttributeDescriptor()\n\t\t\t\t\t\t.getValueGraphType().getJavaType();\n\t\tif ( !attributeValueType.isAssignableFrom( subgraphType ) ) {\n\t\t\tthrow new AnnotationException( \"Named subgraph type '\" + subgraphType.getName()\n\t\t\t\t\t\t+ \"' is not a subtype of the value type '\" + attributeValueType.getName() + \"'\" );\n\t\t}\n\t\treturn attributeNode.addValueSubgraph().addTreatedSubgraph(\n\t\t\t\tsubgraphType.asSubclass( attributeNode.getValueSubgraph().getClassType() ) );\n\t}\n\n\tprivate static <T, E, K> SubGraphImplementor<?> makeAttributeNodeKeySubgraph(\n\t\t\tAttributeNodeImplementor<T, E, K> attributeNode, Class<?> subgraphType) {\n\t\tfinal var attributeKeyType =\n\t\t\t\tattributeNode.getAttributeDescriptor()\n\t\t\t\t\t\t.getKeyGraphType().getJavaType();\n\t\tif ( !attributeKeyType.isAssignableFrom( subgraphType ) ) {\n\t\t\tthrow new AnnotationException( \"Named subgraph type '\" + subgraphType.getName()\n\t\t\t\t\t\t+ \"' is not a subtype of the key type '\" + attributeKeyType.getName() + \"'\" );\n\t\t}\n\t\treturn attributeNode.addKeySubgraph().addTreatedSubgraph(\n\t\t\t\tsubgraphType.asSubclass( attributeNode.getKeySubgraph().getClassType() ) );\n\t}\n}\n","sourceCodeStart":370,"sourceCodeEnd":395,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/NamedGraphCreatorJpa.java#L370-L395","documentation":"Error \"Named subgraph type '${type}' is not a subtype of the key type '${keyType}'\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A named entity graph / fetch declaration references unknown or incompatible types, attributes, or subgraphs.","commonSituations":"@Fetch pointing at an unknown graph, subgraph types that are not subtypes of the attribute type, or conflicting fetch options for the same attribute.","solutions":["Make the named subgraph type a subtype of the map key 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"}