hibernate/hibernate-orm · error · InvalidGraphException

Expecting graph text to include an entity name

Error message

Expecting graph text to include an entity name : {}

What it means

Legacy graph parsing strategy was asked to parse a root graph from text but the string contains no leading entity-name type indicator, which this overload requires to determine the graph's root entity. The offending input is the graphText without an entity name.

Solutions

  1. Prefix the graph text with the entity name as required by the legacy graph parser.
  2. Or switch the graph parser mode to match the text format being passed.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown while parsing entity graph text that does not conform to the expected format for the configured parser mode.

Common situations: Typical situations: including an entity name where the legacy strategy forbids it (or omitting it where required); using parse() with the modern parser mode selected.


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/e7c9e0e4b9db8741. Report an issue: GitHub.

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/graph/internal/parse/strategy/LegacyGraphParsingStrategy.java:48

				new CommonTokenStream( new GraphLanguageLexer( CharStreams.fromString( graphText ) ) ) );
		final var graph = parser.graph();
		if ( graph.typeIndicator() != null ) {
			throw new InvalidGraphException( "Expecting graph text to not include an entity name : " + graphText );
		}
		return parse( entityDomainType, graph.attributeList(), sessionFactory );
	}

	@Override
	@Deprecated(forRemoval = true)
	public <T> RootGraphImplementor<T> parse(String graphText, SessionFactoryImplementor sessionFactory) {
		if ( graphText == null ) {
			return null;
		}
		final var parser = new LegacyGraphLanguageParser(
				new CommonTokenStream( new GraphLanguageLexer( CharStreams.fromString( graphText ) ) ) );
		final var graph = parser.graph();
		if ( graph.typeIndicator() == null ) {
			throw new InvalidGraphException( "Expecting graph text to include an entity name : " + graphText );
		}
		final String entityName = graph.typeIndicator().TYPE_NAME().getText();
		@SuppressWarnings(
				"unchecked") final EntityDomainType<T> entityType = (EntityDomainType<T>) sessionFactory.getJpaMetamodel()
				.entity( entityName );
		return parse( entityType, graph.attributeList(), sessionFactory );
	}

	@Override
	public void parseInto(GraphImplementor<?> graph, String graphText, SessionFactoryImplementor sessionFactory) {
		final var lexer = new GraphLanguageLexer( CharStreams.fromString( graphText ) );
		final var parser = new LegacyGraphLanguageParser( new CommonTokenStream( lexer ) );
		final var graphContext = parser.graph();

		if ( graphContext.typeIndicator() != null ) {
			// todo : throw an exception?  Log warning?  Ignore?
			//		for now, ignore
		}

View on GitHub (pinned to fad1729dce)