{"record":{"id":"b9e0c128686e37c7","repo":"hibernate/hibernate-orm","slug":"named-subgraph-type-type-is-not-a-subtype-of-b9e0c1","errorCode":null,"errorMessage":"Named subgraph type '${type}' is not a subtype of the value type '${valueType}'","messagePattern":"Named subgraph type '(.+?)' is not a subtype of the value type '(.+?)'","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/NamedGraphCreatorJpa.java","lineNumber":375,"sourceCode":"\t\t\tAttributeNodeImplementor<?, ?, ?> attributeNode,\n\t\t\tboolean isKeySubGraph, Class<?> subgraphType) {\n\t\tif ( void.class.equals( subgraphType ) ) { // unspecified\n\t\t\treturn attributeNode.addValueSubgraph();\n\t\t}\n\t\telse {\n\t\t\treturn isKeySubGraph\n\t\t\t\t\t? makeAttributeNodeKeySubgraph( attributeNode, subgraphType )\n\t\t\t\t\t: makeAttributeNodeValueSubgraph( attributeNode, subgraphType );\n\t\t}\n\t}\n\n\tprivate static <T, E, K> SubGraphImplementor<?> makeAttributeNodeValueSubgraph(\n\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}","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/NamedGraphCreatorJpa.java#L357-L393","documentation":"Error \"Named subgraph type '${type}' is not a subtype of the value type '${valueType}'\" 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/collection value 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"}