{"record":{"id":"f20ef807bcac46cd","repo":"hibernate/hibernate-orm","slug":"graph-semantic-cannot-be-null","errorCode":null,"errorMessage":"Graph semantic cannot be null","messagePattern":"Graph semantic cannot be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/engine/spi/EffectiveEntityGraph.java","lineNumber":85,"sourceCode":"\tpublic @Nullable GraphSemantic getSemantic() {\n\t\treturn semantic;\n\t}\n\n\t@Override\n\tpublic @Nullable RootGraphImplementor<?> getGraph() {\n\t\treturn graph;\n\t}\n\n\t/**\n\t * Apply the graph and semantic.  The semantic is required.  The graph\n\t * may be null, but that should generally be considered mis-use.\n\t *\n\t * @throws IllegalArgumentException Thrown if the semantic is null\n\t * @throws IllegalStateException If previous state is still available (hasn't been cleared).\n\t */\n\tpublic void applyGraph(RootGraphImplementor<?> graph, GraphSemantic semantic) {\n\t\tif ( semantic == null ) {\n\t\t\tthrow new IllegalArgumentException( \"Graph semantic cannot be null\" );\n\t\t}\n\t\tverifyWriteability();\n\t\tLOG.tracef( \"Setting effective graph state [%s] : %s\", semantic.name(), graph );\n\t\tthis.semantic = semantic;\n\t\tthis.graph = graph;\n\t}\n\n\tprivate void verifyWriteability() {\n\t\tif ( ! allowOverwrite ) {\n\t\t\tif ( semantic != null ) {\n\t\t\t\tthrow new IllegalStateException( \"Cannot overwrite existing state, should clear previous state first\" );\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Apply a graph and semantic based on configuration properties or hints\n\t * based on {@link GraphSemantic#getJakartaHintName()} for {@link GraphSemantic#LOAD} or","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/engine/spi/EffectiveEntityGraph.java#L67-L103","documentation":"Error \"Graph semantic cannot be null\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown at hibernate-core/src/main/java/org/hibernate/engine/spi/EffectiveEntityGraph.java:85 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass an explicit GraphSemantic (FETCHGRAPH or LOADGRAPH) instead of null","Use the overloaded method that infers the semantic when only a graph is given"],"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"}