hibernate/hibernate-orm · error · UnsupportedOperationException

Parsing of graph text is not supported with 'modern' graph…

Error message

Parsing of graph text is not supported with 'modern' graph parser mode

What it means

ModernGraphParsingStrategy's entity-name-inferencing parse overload is intentionally unimplemented: with the modern parser you must always supply the root EntityDomainType explicitly. UnsupportedOperationException by design.

Solutions

  1. Build the graph programmatically with the EntityGraph API when using the modern parser mode.
  2. Or switch the graph parser mode to legacy if textual parsing is required.
Defensive patterns

Strategy: fallback

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/0f9c834fd5feb480. Report an issue: GitHub.

Appendix: source

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

	@Override
	public <T> RootGraphImplementor<T> parse(
			EntityDomainType<T> entityDomainType,
			String graphText,
			SessionFactoryImplementor sessionFactory) {
		if ( graphText == null ) {
			return null;
		}
		final var parser = new GraphLanguageParser( new CommonTokenStream( new GraphLanguageLexer(
				CharStreams.fromString( graphText ) ) ) );
		final var graph = parser.graph();

		return parse( entityDomainType, graph.graphElementList(), sessionFactory );
	}

	@Override
	public <T> RootGraphImplementor<T> parse(String graphText, SessionFactoryImplementor sessionFactory) {
		throw new UnsupportedOperationException(
				"Parsing of graph text is not supported with 'modern' graph parser mode" );
	}

	@Override
	public void parseInto(GraphImplementor<?> graph, String graphText, SessionFactoryImplementor sessionFactory) {
		final var parser = new GraphLanguageParser( new CommonTokenStream( new GraphLanguageLexer(
				CharStreams.fromString( graphText ) ) ) );
		final var graphCtx = parser.graph();
		final var visitor = new GraphParser( sessionFactory );
		visitor.getGraphStack().push( graph );
		try {
			visitor.visitGraphElementList( graphCtx.graphElementList() );
		}
		finally {
			visitor.getGraphStack().pop();
			assert visitor.getGraphStack().isEmpty();
		}
	}

View on GitHub (pinned to fad1729dce)