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

Error "Expecting graph text to include an entity name : {}" thrown in hibernate/hibernate-orm.

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)

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.

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.