hibernate/hibernate-orm · error · UnsupportedOperationException

Unsupported path source: ${domainType}

Error message

Unsupported path source: ${domainType}

What it means

AnonymousTupleSqmPathSource.createSqmPath builds a concrete path for exactly three domain type kinds: basic (BasicDomainType), embeddable (EmbeddableDomainType) and entity (EntityDomainType). If the referenced attribute's type is anything else — most commonly a MappedSuperclass type, an 'any' mappings type, or another synthetic SqmExpressible — path creation has no implementation and throws UnsupportedOperationException 'Unsupported path source: <type>'. This surfaces when query code tries to keep navigating (get(...)) through a tuple attribute that is not navigable.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/sqm/tuple/internal/AnonymousTupleSqmPathSource.java:97

		}
		else if ( domainType instanceof EmbeddableDomainType<?> ) {
			return new SqmEmbeddedValuedSimplePath<>(
					PathHelper.append( lhs, this, intermediatePathSource ),
					this,
					lhs,
					lhs.nodeBuilder()
			);
		}
		else if ( domainType instanceof EntityDomainType<?> ) {
			return new SqmEntityValuedSimplePath<>(
					PathHelper.append( lhs, this, intermediatePathSource ),
					this,
					lhs,
					lhs.nodeBuilder()
			);
		}

		throw new UnsupportedOperationException( "Unsupported path source: " + domainType );
	}
}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Restrict navigation to attributes whose type is basic, embeddable or entity; treat basic attributes as leaf values (read them, don't navigate them)
  2. Type the tuple/CTE attribute by a concrete @Entity or embeddable instead of a mapped superclass or polymorphic type
  3. In generic walkers, check the domain type kind before creating sub-paths and skip/stop at unsupported kinds

Example fix

// before
JpaCteCriteria<?> cte = query.with("data", ...);
SqmPath<?> owner = cteRoot.get("owner"); // owner typed as a @MappedSuperclass
SqmPath<?> name = owner.get("name"); // UnsupportedOperationException: Unsupported path source

// after — type the CTE attribute by the concrete entity
cb.select(cteRoot.get("owner")); // concrete User type, navigation works
Defensive patterns

Strategy: type-guard

Validate before calling

SqmPathSource<?> src = (SqmPathSource<?>) attribute;
DomainType<?> t = src.getPathType();
if (!(t instanceof BasicDomainType || t instanceof EmbeddableDomainType || t instanceof EntityDomainType)) { /* not navigable — stop or select its value directly */ }

Type guard

static boolean isNavigableTupleAttribute(SqmPathSource<?> src) {
    DomainType<?> t = src.getPathType();
    return t instanceof BasicDomainType || t instanceof EmbeddableDomainType || t instanceof EntityDomainType;
}

Try / catch

try { sub = path.get(name); } catch (UnsupportedOperationException e) { if (e.getMessage().startsWith("Unsupported path source")) { /* stop navigation; select attribute as leaf value */ } else throw e; }

Prevention

When it happens

Trigger: Navigating further through a tuple-typed attribute, e.g. cteRoot.get("owner") where 'owner' resolves to a mapped-superclass or other non-basic/embeddable/entity type, then calling .get(...) on the result; generic path walkers that unconditionally call createSqmPath/findSubPathSource chains.

Common situations: CTE/tuple queries whose attributes are typed by abstract hierarchy roots (@MappedSuperclass); polymorphic reference attributes; generic criteria-tree rewriters (count-query generators, DTO projectors) that dereference every path.

Related errors


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