hibernate/hibernate-orm · error · UnsupportedMappingException
AnonymousTupleType cannot be used to create an SqmPath - tha
Error message
AnonymousTupleType cannot be used to create an SqmPath - that would be an SqmFrom which are created directly
What it means
AnonymousTupleType implements SqmPathSource, but a path over an anonymous tuple would have to be an SqmFrom, and SQM creates SqmFrom elements directly for from-clause roots. createSqmPath therefore always throws UnsupportedMappingException - the tuple type is not a navigable you can join or path-create through.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/query/sqm/tuple/internal/AnonymousTupleType.java:284
@Override
public String getPathName() {
return "tuple" + System.identityHashCode( this );
}
@Override
public SqmDomainType<T> getPathType() {
return this;
}
@Override
public @Nullable SqmDomainType<T> getSqmType() {
return this;
}
@Override
public SqmPath<T> createSqmPath(SqmPath<?> lhs, @Nullable SqmPathSource<?> intermediatePathSource) {
throw new UnsupportedMappingException(
"AnonymousTupleType cannot be used to create an SqmPath - that would be an SqmFrom which are created directly"
);
}
@Override
@Nonnull
public Class<T> getBindableJavaType() {
return javaTypeDescriptor.getJavaTypeClass();
}
@Override
@Nonnull
public Class<T> getJavaType() {
return javaTypeDescriptor.getJavaTypeClass();
}
@Override
public String toString() {View on GitHub (pinned to fad1729dce)
Solutions
- Navigate only the tuple's component aliases (t.id, t.name); never join or fetch from the tuple root.
- If you need association navigation, use a real mapped entity in the CTE/from clause instead of an anonymous tuple.
- Rewrite joins over CTE results as IN/correlated subqueries against the component columns.
- Upgrade Hibernate ORM - tuple handling improves across 6.x releases and may support your shape later.
Example fix
// before - treating the tuple as a joinable managed type "with c as (select e.id as id from Entity e) select o.total from c join c.order o" // -> UnsupportedMappingException: AnonymousTupleType cannot be used to create an SqmPath // after - join real entities, use the tuple only for scalar filtering "select o.total from Order o where o.id in (select c.id from c)"
Defensive patterns
Strategy: try-catch
Try / catch
try {
return session.createQuery(hql).getResultList();
} catch (UnsupportedMappingException e) {
// tuple treated as navigable/joinable type; navigate component aliases only
throw new QueryDesignException("CTE tuple cannot be joined or path-navigated: " + hql, e);
} Prevention
- Never join, fetch or treat CTE tuple roots as managed types.
- Use CTEs for scalar filtering (IN subqueries) and join real entities instead.
- Map persistent row shapes as entities/embeddables when association navigation is needed.
When it happens
Trigger: Query translation or programmatic SQM calls createSqmPath with the tuple type as the path source: treating the CTE/subquery tuple like a managed type by joining to it, fetching from it, using treat expressions, or building paths off it in custom criteria code.
Common situations: Writing HQL that treats a CTE root as an entity (join/fetch off `cteRoot.someAssociation`); criteria frameworks that call createSqmPath generically on every path source; upgrading applications that previously used native SQL for these shapes.
Related errors
- Unsupported path source: ${domainType}
- Unsupported path source: ${sqmPathType}
- Could not resolve attribute '%s' of '%s' due to the attribut
- Cte root does not have an entity type. Use getReferencedPath
- Tuple constructor must have at least one element
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/0a875a50f7e8b59a.
Report an issue: GitHub.