hibernate/hibernate-orm · error · IllegalArgumentException

GraphSemantic option was specified, but no Graph was supplie

Error message

GraphSemantic option was specified, but no Graph was supplied

What it means

Error "GraphSemantic option was specified, but no Graph was supplied" thrown in hibernate/hibernate-orm.

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)

Solutions

  1. When specifying a GraphSemantic (FETCH/LOAD), also supply the corresponding EntityGraph via the graph option.
  2. Remove the GraphSemantic option if no graph is needed.

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.