hibernate/hibernate-orm · error · AnnotationException
Attribute '${attribute}' has conflicting '@Fetch' options fo
Error message
Attribute '${attribute}' has conflicting '@Fetch' options for graph '${graph}': ${first} and ${second} What it means
Error "Attribute '${attribute}' has conflicting '@Fetch' options for graph '${graph}': ${first} and ${second}" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/NamedGraphCreatorJpa.java:198
private static boolean sameFetchTarget(FetchGraphContribution first, FetchGraphContribution second) {
return first.graphName().equals( second.graphName() )
&& first.attributeName().equals( second.attributeName() )
&& targetsSameGraphNode( first.subgraphNames(), second.subgraphNames() );
}
private static boolean targetsSameGraphNode(String[] firstSubgraphs, String[] secondSubgraphs) {
if ( firstSubgraphs.length == 0 || secondSubgraphs.length == 0 ) {
return firstSubgraphs.length == secondSubgraphs.length;
}
return Arrays.stream( firstSubgraphs ).anyMatch( first -> Arrays.asList( secondSubgraphs ).contains( first ) );
}
private static void validateCompatibleOptions(FetchGraphContribution first, FetchGraphContribution second) {
for ( var firstOption : first.options() ) {
for ( var secondOption : second.options() ) {
if ( firstOption.getClass() == secondOption.getClass() && !firstOption.equals( secondOption ) ) {
throw new AnnotationException(
"Attribute '" + first.attributeName()
+ "' has conflicting '@Fetch' options for graph '"
+ first.graphName() + "': " + firstOption + " and " + secondOption );
}
}
}
}
private boolean isNamedSubgraph(String subgraphName) {
for ( var namedSubgraph : annotation.subgraphs() ) {
if ( subgraphName.equals( namedSubgraph.name() ) ) {
return true;
}
}
return false;
}
private void applyFetchContributions(View on GitHub (pinned to fad1729dce)
Solutions
- Remove the conflicting @Fetch options so only one fetch mode applies to the attribute in the graph.
When it happens
Trigger: A named entity graph / fetch declaration references unknown or incompatible types, attributes, or subgraphs.
Common situations: @Fetch pointing at an unknown graph, subgraph types that are not subtypes of the attribute type, or conflicting fetch options for the same attribute.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/134417eadf9d0f06.
Report an issue: GitHub.