hibernate/hibernate-orm · error · UnsupportedOperationException

Polymorphic query group is unsupported

Error message

Polymorphic query group is unsupported

What it means

Error "Polymorphic query group is unsupported" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/hql/internal/QuerySplitter.java:64

		for ( EntityDomainType<?> mappedDescriptor : implementors ) {
			expanded[i++] = copyStatement( statement, unmappedPolymorphicReference, mappedDescriptor );
		}
		return expanded;
	}

	private static SqmRoot<?> findUnmappedPolymorphicReference(SqmQueryPart<?> queryPart) {
		if ( queryPart instanceof SqmQuerySpec<?> sqmQuerySpec ) {
			return sqmQuerySpec.getRoots()
					.stream()
					.filter( sqmRoot -> sqmRoot.getReferencedPathSource() instanceof SqmPolymorphicRootDescriptor )
					.findFirst()
					.orElse( null );
		}
		else {
			final SqmQueryGroup<?> queryGroup = (SqmQueryGroup<?>) queryPart;
			final SqmRoot<?> root = findUnmappedPolymorphicReference( queryGroup.getQueryParts().get( 0 ) );
			if ( root != null ) {
				throw new UnsupportedOperationException( "Polymorphic query group is unsupported" );
			}
			return null;
		}
	}

	@SuppressWarnings( { "unchecked", "rawtypes" } )
	private static <S extends SqmStatement<?>> S copyStatement(
			S statement,
			SqmRoot unmappedPolymorphicReference,
			EntityDomainType<?> mappedDescriptor) {
		// We never want to copy parameters when splitting polymorphic queries, as that
		// would cause losing their binding information as that's stored by instance,
		// so we always return the original object instead
		final SqmCopyContext context = SqmCopyContext.noParamCopyContext();
		// Copy the statement replacing the root's unmapped polymorphic reference with
		// the concrete mapped descriptor entity domain type.
		final var path = context.registerCopy(
				unmappedPolymorphicReference,

View on GitHub (pinned to fad1729dce)

Solutions

  1. Split the polymorphic query into per-type queries explicitly.
  2. Query the concrete entity types separately.

When it happens

Trigger: A runtime precondition of the Hibernate API is violated.

Common situations: Occurs when application code or configuration does not satisfy the documented contract of the API being called.


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