hibernate/hibernate-orm · error · IllegalArgumentException
GraphSemantic option was specified, but no Graph was…
Error message
GraphSemantic option was specified, but no Graph was supplied
What it means
Find-option validation in AbstractFindByKeyOperation: a GraphSemantic option was passed but no accompanying RootGraph was supplied, so the graph semantic cannot be applied. Pass the graph together with the semantic.
Solutions
- When specifying a GraphSemantic (FETCH/LOAD), also supply the corresponding EntityGraph via the graph option.
- Remove the GraphSemantic option if no graph is needed.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at hibernate-core/src/main/java/org/hibernate/internal/find/AbstractFindByKeyOperation.java:164 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/49743bc925c2d6f2.
Report an issue: GitHub.
Appendix: source
Thrown at hibernate-core/src/main/java/org/hibernate/internal/find/AbstractFindByKeyOperation.java:164
}
else if ( option instanceof Locking.FollowOn followOn ) {
this.lockFollowOn = followOn;
}
else if ( option instanceof Timeout timeout ) {
this.lockTimeout = timeout;
}
else if ( option instanceof ReadOnlyMode readOnlyMode ) {
this.readOnlyMode = readOnlyMode;
}
else if ( option instanceof EnabledFetchProfile enabledFetchProfile ) {
this.enabledFetchProfile( enabledFetchProfile.profileName() );
}
else if ( option instanceof NaturalIdSynchronization naturalIdSynchronization ) {
this.naturalIdSynchronization = naturalIdSynchronization;
}
else if ( option instanceof GraphSemantic graphSemanticOption ) {
if ( rootGraph == null ) {
throw new IllegalArgumentException(
"GraphSemantic option was specified, but no Graph was supplied" );
}
this.graphSemantic = graphSemanticOption;
}
else if ( option instanceof FindMultipleOption findMultipleOption ) {
throw new IllegalArgumentException(
"Option '" + findMultipleOption + "' can only be used in 'findMultiple()'" );
}
}
}
}
private void enabledFetchProfile(String profileName) {
if ( enabledFetchProfiles == null ) {
enabledFetchProfiles = new HashSet<>();
}
enabledFetchProfiles.add( profileName );
}View on GitHub (pinned to fad1729dce)