hibernate/hibernate-orm · error · IllegalArgumentException
Graph semantic specified, but no RootGraph was supplied
Error message
Graph semantic specified, but no RootGraph was supplied
What it means
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.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/engine/spi/LoadQueryInfluencers.java:115
temporalIdentifier = options.getTemporalIdentifier();
for ( var filterDefinition : sessionFactory.getAutoEnabledFilters() ) {
final var filter = new FilterImpl( filterDefinition );
if ( enabledFilters == null ) {
enabledFilters = new TreeMap<>();
}
enabledFilters.put( filterDefinition.getFilterName(), filter );
}
for ( var enabledFilterOption : options.getEnabledFilterOptions() ) {
enableFilter( enabledFilterOption );
}
}
@Nonnull
public EffectiveEntityGraph applyEntityGraph(RootGraphImplementor<?> rootGraph, GraphSemantic graphSemantic) {
final var effectiveEntityGraph = getEffectiveEntityGraph();
if ( graphSemantic != null ) {
if ( rootGraph == null ) {
throw new IllegalArgumentException( "Graph semantic specified, but no RootGraph was supplied" );
}
effectiveEntityGraph.applyGraph( rootGraph, graphSemantic );
}
return effectiveEntityGraph;
}
@Nonnull
public SessionFactoryImplementor getSessionFactory() {
return sessionFactory;
}
@Nullable
public Object getTemporalIdentifier() {
return temporalIdentifier;
}
public void setTemporalIdentifier(@Nullable Object temporalIdentifier) {
this.temporalIdentifier = temporalIdentifier;View on GitHub (pinned to fad1729dce)
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
Example fix
// before
RootGraphImplementor<?> graph = graphs.get("orderGraph"); // null if not registered
influencers.applyEntityGraph(graph, GraphSemantic.FETCH); // IllegalArgumentException
// after
RootGraphImplementor<?> graph = graphs.get("orderGraph");
if (graph == null) throw new IllegalStateException("Entity graph 'orderGraph' is not registered");
influencers.applyEntityGraph(graph, GraphSemantic.FETCH); Defensive patterns
Strategy: validation
Validate before calling
if (semantic != null && rootGraph == null) {
throw new IllegalArgumentException("A RootGraph is required when a GraphSemantic (" + semantic + ") is specified");
}
influencers.applyEntityGraph(rootGraph, semantic); Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Passed properties contained both a LOAD and a FETCH graph wh
- Informix only supports the case insensitive flag 'i' as lite
- Duplicate named entity graph '%s'
- The 'root' parameter of the @NamedEntityGraph should be pass
- The 'root' parameter of the @NamedEntityGraph annotation mus
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/36944135217bfc21.
Report an issue: GitHub.