hibernate/hibernate-orm · error · InvalidGraphException

Expecting graph text to not include an entity name : {}

Error message

Expecting graph text to not include an entity name : {}

What it means

Error "Expecting graph text to not 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:33

import org.hibernate.graph.internal.parse.LegacyGraphParser;
import org.hibernate.graph.spi.GraphImplementor;
import org.hibernate.graph.spi.GraphParserEntityNameResolver;
import org.hibernate.graph.spi.RootGraphImplementor;
import org.hibernate.metamodel.model.domain.EntityDomainType;

@Deprecated(forRemoval = true)
public class LegacyGraphParsingStrategy implements GraphParsingStrategy {

	@Override
	public <T> RootGraphImplementor<T> parse(EntityDomainType<T> entityDomainType, 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 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(

View on GitHub (pinned to fad1729dce)

Solutions

  1. Remove the entity name prefix from the graph text when the parsing strategy does not expect it.
  2. Pass the graph text in the legacy format expected by the configured parser mode.

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/3424cf82467129b9. Report an issue: GitHub.