{"record":{"id":"358b1fb21c983735","repo":"hibernate/hibernate-orm","slug":"named-subgraph-type-type-is-not-a-subtype-of","errorCode":null,"errorMessage":"Named subgraph type '${type}' is not a subtype of the graph type '${graphType}'","messagePattern":"Named subgraph type '(.+?)' is not a subtype of the graph type '(.+?)'","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/NamedGraphCreatorJpa.java","lineNumber":85,"sourceCode":"\tpublic RootGraphImplementor<?> createEntityGraph(\n\t\t\tGraphParserEntityClassResolver entityDomainClassResolver,\n\t\t\tGraphParserEntityNameResolver entityDomainNameResolver,\n\t\t\tServiceRegistry serviceRegistry) {\n\t\treturn createGraph( (EntityDomainType<?>)\n\t\t\t\tentityDomainNameResolver.resolveEntityName( jpaEntityName ) );\n\t}\n\n\tprivate <T> @Nonnull RootGraphImplementor<T> createGraph(EntityDomainType<T> rootEntityType) {\n\t\tvalidateFetchContributions();\n\t\tfinal var entityGraph =\n\t\t\t\tcreateRootGraph( name, rootEntityType, annotation.includeAllAttributes() );\n\t\tfinal var subclassSubgraphs = annotation.subclassSubgraphs();\n\t\tif ( subclassSubgraphs != null ) {\n\t\t\tfor ( var subclassSubgraph : subclassSubgraphs ) {\n\t\t\t\tfinal var subgraphType = subclassSubgraph.type();\n\t\t\t\tfinal var graphJavaType = entityGraph.getGraphedType().getJavaType();\n\t\t\t\tif ( !graphJavaType.isAssignableFrom( subgraphType ) ) {\n\t\t\t\t\tthrow new AnnotationException( \"Named subgraph type '\" + subgraphType.getName()\n\t\t\t\t\t\t\t\t+ \"' is not a subtype of the graph type '\" + graphJavaType.getName() + \"'\" );\n\t\t\t\t}\n\t\t\t\tapplyNamedAttributeNodes( subclassSubgraph.attributeNodes(), annotation,\n\t\t\t\t\t\tentityGraph.addTreatedSubgraph( subgraphType.asSubclass( graphJavaType ) ), \"\", fetchContributions );\n\t\t\t}\n\t\t}\n\t\tif ( annotation.attributeNodes() != null ) {\n\t\t\tapplyNamedAttributeNodes( annotation.attributeNodes(), annotation, entityGraph, null, fetchContributions );\n\t\t}\n\t\telse {\n\t\t\tapplyFetchContributions( entityGraph, null, fetchContributions, name );\n\t\t}\n\t\treturn entityGraph;\n\t}\n\n\tprivate static <T> RootGraphImplementor<T> createRootGraph(\n\t\t\tString name,\n\t\t\tEntityDomainType<T> rootEntityType,","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/NamedGraphCreatorJpa.java#L67-L103","documentation":"Error \"Named subgraph type '${type}' is not a subtype of the graph type '${graphType}'\" 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 entity graph root 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"}