{"record":{"id":"36944135217bfc21","repo":"hibernate/hibernate-orm","slug":"graph-semantic-specified-but-no-rootgraph-was-sup","errorCode":null,"errorMessage":"Graph semantic specified, but no RootGraph was supplied","messagePattern":"Graph semantic specified, but no RootGraph was supplied","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/engine/spi/LoadQueryInfluencers.java","lineNumber":115,"sourceCode":"\t\ttemporalIdentifier = options.getTemporalIdentifier();\n\t\tfor ( var filterDefinition : sessionFactory.getAutoEnabledFilters() ) {\n\t\t\tfinal var filter = new FilterImpl( filterDefinition );\n\t\t\tif ( enabledFilters == null ) {\n\t\t\t\tenabledFilters = new TreeMap<>();\n\t\t\t}\n\t\t\tenabledFilters.put( filterDefinition.getFilterName(), filter );\n\t\t}\n\t\tfor ( var enabledFilterOption : options.getEnabledFilterOptions() ) {\n\t\t\tenableFilter( enabledFilterOption );\n\t\t}\n\t}\n\n\t@Nonnull\n\tpublic EffectiveEntityGraph applyEntityGraph(RootGraphImplementor<?> rootGraph, GraphSemantic graphSemantic) {\n\t\tfinal var effectiveEntityGraph = getEffectiveEntityGraph();\n\t\tif ( graphSemantic != null ) {\n\t\t\tif ( rootGraph == null ) {\n\t\t\t\tthrow new IllegalArgumentException( \"Graph semantic specified, but no RootGraph was supplied\" );\n\t\t\t}\n\t\t\teffectiveEntityGraph.applyGraph( rootGraph, graphSemantic );\n\t\t}\n\t\treturn effectiveEntityGraph;\n\t}\n\n\t@Nonnull\n\tpublic SessionFactoryImplementor getSessionFactory() {\n\t\treturn sessionFactory;\n\t}\n\n\t@Nullable\n\tpublic Object getTemporalIdentifier() {\n\t\treturn temporalIdentifier;\n\t}\n\n\tpublic void setTemporalIdentifier(@Nullable Object temporalIdentifier) {\n\t\tthis.temporalIdentifier = temporalIdentifier;","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/engine/spi/LoadQueryInfluencers.java#L97-L133","documentation":"LoadQueryInfluencers.applyEntityGraph(rootGraph, graphSemantic) requires the two arguments to be non-null together: naming a GraphSemantic (FETCH or LOAD) means a graph must be supplied to interpret, so a null RootGraph with a non-null semantic is rejected with IllegalArgumentException.","triggerScenarios":"Calling loadQueryInfluencers.applyEntityGraph(null, GraphSemantic.FETCH/LOAD) directly, or through the by-key/find-by-id load-access and find operations that pass a looked-up graph: a graph registry lookup (e.g. getEntityGraph(name)) returned null because the graph was never registered, and it was passed alongside a non-null semantic.","commonSituations":"Graphs looked up by name from a map or configuration that silently returned null; refactoring that made the graph argument optional; test code passing null placeholders; copy-paste from applyConfiguredGraph() flows where a null graph is only warned about.","solutions":["Pass a real RootGraph obtained from session.createEntityGraph(Class) / em.createEntityGraph(Class) or em.getEntityGraph(name)","If the graph is genuinely optional, pass a null semantic as well — applyEntityGraph then leaves the effective graph untouched","Null-check the graph before calling and fail fast with a descriptive message identifying the missing graph"],"exampleFix":"// before\nRootGraphImplementor<?> graph = graphs.get(\"orderGraph\"); // null if not registered\ninfluencers.applyEntityGraph(graph, GraphSemantic.FETCH); // IllegalArgumentException\n\n// after\nRootGraphImplementor<?> graph = graphs.get(\"orderGraph\");\nif (graph == null) throw new IllegalStateException(\"Entity graph 'orderGraph' is not registered\");\ninfluencers.applyEntityGraph(graph, GraphSemantic.FETCH);","handlingStrategy":"validation","validationCode":"if (semantic != null && rootGraph == null) {\n    throw new IllegalArgumentException(\"A RootGraph is required when a GraphSemantic (\" + semantic + \") is specified\");\n}\ninfluencers.applyEntityGraph(rootGraph, semantic);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve graphs via em.getEntityGraph(name)/createEntityGraph(...) and fail fast when lookup returns null","Keep semantic and graph as one non-null 'optional pair' type so they cannot diverge","Null-check the pair together at the API boundary instead of relying on Hibernate's internal check"],"tags":["hibernate","entity-graph","null-argument","illegal-argument","load-influencers"],"backgroundTag":"missing-required-graph","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}