{"record":{"id":"56eb0d24c1a8c1bf","repo":"hibernate/hibernate-orm","slug":"unsupported-path-source-sqmpathtype","errorCode":null,"errorMessage":"Unsupported path source: ${sqmPathType}","messagePattern":"Unsupported path source: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/sqm/tuple/internal/AnonymousTupleSqmPathSourceNew.java","lineNumber":93,"sourceCode":"\t\t}\n\t\telse if ( sqmPathType instanceof EmbeddableDomainType<?> ) {\n\t\t\treturn new SqmEmbeddedValuedSimplePath<>(\n\t\t\t\t\tPathHelper.append( lhs, this, intermediatePathSource ),\n\t\t\t\t\tthis,\n\t\t\t\t\tlhs,\n\t\t\t\t\tlhs.nodeBuilder()\n\t\t\t);\n\t\t}\n\t\telse if ( sqmPathType instanceof EntityDomainType<?> ) {\n\t\t\treturn new SqmEntityValuedSimplePath<>(\n\t\t\t\t\tPathHelper.append( lhs, this, intermediatePathSource ),\n\t\t\t\t\tthis,\n\t\t\t\t\tlhs,\n\t\t\t\t\tlhs.nodeBuilder()\n\t\t\t);\n\t\t}\n\n\t\tthrow new UnsupportedOperationException( \"Unsupported path source: \" + sqmPathType );\n\t}\n}\n","sourceCodeStart":75,"sourceCodeEnd":96,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/sqm/tuple/internal/AnonymousTupleSqmPathSourceNew.java#L75-L96","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Only navigate through tuple attributes typed as embeddable or entity; treat basic-typed attributes as leaves","Give the CTE/tuple attribute a concrete @Entity or @Embeddable type instead of a mapped superclass or polymorphic type","In generic tree walkers, switch on the attribute's domain type before creating sub-paths and stop at unsupported kinds"],"exampleFix":"// before\nSqmPath<?> attr = tupleRoot.get(\"category\"); // category typed by @MappedSuperclass BaseCategory\ncb.equal(attr.get(\"id\"), 1); // UnsupportedOperationException: Unsupported path source\n\n// after — project the concrete subtype attribute\ncb.equal(tupleRoot.get(\"categoryId\"), 1); // basic-typed attribute, no navigation needed","handlingStrategy":"type-guard","validationCode":"DomainType<?> t = ((SqmPathSource<?>) attr).getPathType();\nif (!(t instanceof BasicDomainType || t instanceof EmbeddableDomainType || t instanceof EntityDomainType)) { /* stop navigation here */ }","typeGuard":"static boolean isNavigable(SqmPathSource<?> s) { DomainType<?> t = s.getPathType(); return t instanceof BasicDomainType || t instanceof EmbeddableDomainType || t instanceof EntityDomainType; }","tryCatchPattern":"try { child = parent.get(name); } catch (UnsupportedOperationException e) { if (e.getMessage().startsWith(\"Unsupported path source\")) child = null; else throw e; }","preventionTips":["Avoid navigating through tuple attributes typed by abstract/mapped-superclass types","Prefer basic-typed columns (id, name) in CTE projections when deeper navigation isn't needed","Test criteria rewrites against CTE-heavy queries after every Hibernate upgrade"],"tags":["hibernate","path-navigation","tuple","sqm","cte","mapped-superclass"],"backgroundTag":"unsupported-path-source-type","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}