{"record":{"id":"134417eadf9d0f06","repo":"hibernate/hibernate-orm","slug":"attribute-attribute-has-conflicting-fetch","errorCode":null,"errorMessage":"Attribute '${attribute}' has conflicting '@Fetch' options for graph '${graph}': ${first} and ${second}","messagePattern":"Attribute '(.+?)' has conflicting '@Fetch' options for graph '(.+?)': (.+?) and (.+?)","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/NamedGraphCreatorJpa.java","lineNumber":198,"sourceCode":"\n\tprivate static boolean sameFetchTarget(FetchGraphContribution first, FetchGraphContribution second) {\n\t\treturn first.graphName().equals( second.graphName() )\n\t\t\t&& first.attributeName().equals( second.attributeName() )\n\t\t\t&& targetsSameGraphNode( first.subgraphNames(), second.subgraphNames() );\n\t}\n\n\tprivate static boolean targetsSameGraphNode(String[] firstSubgraphs, String[] secondSubgraphs) {\n\t\tif ( firstSubgraphs.length == 0 || secondSubgraphs.length == 0 ) {\n\t\t\treturn firstSubgraphs.length == secondSubgraphs.length;\n\t\t}\n\t\treturn Arrays.stream( firstSubgraphs ).anyMatch( first -> Arrays.asList( secondSubgraphs ).contains( first ) );\n\t}\n\n\tprivate static void validateCompatibleOptions(FetchGraphContribution first, FetchGraphContribution second) {\n\t\tfor ( var firstOption : first.options() ) {\n\t\t\tfor ( var secondOption : second.options() ) {\n\t\t\t\tif ( firstOption.getClass() == secondOption.getClass() && !firstOption.equals( secondOption ) ) {\n\t\t\t\t\tthrow new AnnotationException(\n\t\t\t\t\t\t\t\"Attribute '\" + first.attributeName()\n\t\t\t\t\t\t\t\t\t+ \"' has conflicting '@Fetch' options for graph '\"\n\t\t\t\t\t\t\t\t\t+ first.graphName() + \"': \" + firstOption + \" and \" + secondOption );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate boolean isNamedSubgraph(String subgraphName) {\n\t\tfor ( var namedSubgraph : annotation.subgraphs() ) {\n\t\t\tif ( subgraphName.equals( namedSubgraph.name() ) ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate void applyFetchContributions(","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/NamedGraphCreatorJpa.java#L180-L216","documentation":"Error \"Attribute '${attribute}' has conflicting '@Fetch' options for graph '${graph}': ${first} and ${second}\" 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":["Remove the conflicting @Fetch options so only one fetch mode applies to the attribute in the graph."],"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"}