hibernate/hibernate-orm · error · UnsupportedOperationException

Unsupported path source: ${sqmPathType}

Error message

Unsupported path source: ${sqmPathType}

What it means

AnonymousTupleSqmPathSourceNew is the variant path source Hibernate builds for tuple-typed (CTE / dynamic instantiation) attributes on newer code paths. Like its counterpart it only knows how to create paths for basic, embeddable and entity SqmPathTypes; any other type (mapped superclass, 'any' mapping, exotic SqmExpressible) makes createSqmPath throw UnsupportedOperationException 'Unsupported path source: <type>'. It fires when code continues to navigate through a tuple attribute whose type is not navigable.

Source

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

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

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

View on GitHub (pinned to fad1729dce)

Solutions

  1. Only navigate through tuple attributes typed as embeddable or entity; treat basic-typed attributes as leaves
  2. Give the CTE/tuple attribute a concrete @Entity or @Embeddable type instead of a mapped superclass or polymorphic type
  3. In generic tree walkers, switch on the attribute's domain type before creating sub-paths and stop at unsupported kinds

Example fix

// before
SqmPath<?> attr = tupleRoot.get("category"); // category typed by @MappedSuperclass BaseCategory
cb.equal(attr.get("id"), 1); // UnsupportedOperationException: Unsupported path source

// after — project the concrete subtype attribute
cb.equal(tupleRoot.get("categoryId"), 1); // basic-typed attribute, no navigation needed
Defensive patterns

Strategy: type-guard

Validate before calling

DomainType<?> t = ((SqmPathSource<?>) attr).getPathType();
if (!(t instanceof BasicDomainType || t instanceof EmbeddableDomainType || t instanceof EntityDomainType)) { /* stop navigation here */ }

Type guard

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

Try / catch

try { child = parent.get(name); } catch (UnsupportedOperationException e) { if (e.getMessage().startsWith("Unsupported path source")) child = null; else throw e; }

Prevention

When it happens

Trigger: Calling get(...) through an anonymous tuple attribute whose getPathType() is neither basic, embeddable nor entity — e.g., a CTE attribute typed by an abstract/@MappedSuperclass type, or a treat/polymorphic expression — from hand-written criteria or from generic path-walking code.

Common situations: Hibernate 6.x CTE queries typed by domain hierarchies; count-query or DTO-projection generators that dereference every attribute of every path; queries written against entity models that later gained mapped-superclass indirections.

Related errors


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