{"record":{"id":"955282f18de2127d","repo":"hibernate/hibernate-orm","slug":"path-continuation-from-naturalid-reference-not","errorCode":null,"errorMessage":"Path continuation from 'naturalid()' reference not yet implemented","messagePattern":"Path continuation from 'naturalid\\(\\)' reference not yet implemented","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java","lineNumber":3582,"sourceCode":"\t\t\tfinal var versionAttribute = identifiableType.findVersionAttribute();\n\t\t\tassert versionAttribute != null; // Safe, we just checked hasVersionAttribute()\n\t\t\treturn sqmPath.get( versionAttribute );\n\t\t}\n\t\telse {\n\t\t\tthrow new FunctionArgumentException( \"Argument '\" + sqmPath.getNavigablePath()\n\t\t\t\t\t\t+ \"' of 'version()' does not resolve to an entity type\" );\n\t\t}\n\t}\n\n\t@Override\n\tpublic SqmPath<?> visitEntityNaturalIdExpression(HqlParser.EntityNaturalIdExpressionContext ctx) {\n\t\treturn visitEntityNaturalIdReference( ctx.entityNaturalIdReference() );\n\t}\n\n\t@Override\n\tpublic SqmPath<?> visitEntityNaturalIdReference(HqlParser.EntityNaturalIdReferenceContext ctx) {\n\t\tif ( ctx.pathContinuation() != null ) {\n\t\t\tthrow new UnsupportedOperationException( \"Path continuation from 'naturalid()' reference not yet implemented\" );\n\t\t}\n\t\treturn handleNaturalIdPath( consumeDomainPath( ctx.path() ) );\n\t}\n\n\tprivate static <U> SqmPath<?> handleNaturalIdPath(SqmPath<U> sqmPath) {\n\t\tif ( sqmPath.getReferencedPathSource().getPathType()\n\t\t\t\tinstanceof AbstractIdentifiableType<U> identifiableType ) {\n\t\t\tfinal var attributes = identifiableType.findNaturalIdAttributes();\n\t\t\tif ( attributes == null ) {\n\t\t\t\tthrow new FunctionArgumentException( \"Argument '\" + sqmPath.getNavigablePath()\n\t\t\t\t\t\t\t+ \"' of 'naturalid()' is a '\" + identifiableType.getTypeName()\n\t\t\t\t\t\t\t+ \"' and does not have a natural id\"\n\t\t\t\t);\n\t\t\t}\n\t\t\telse if ( attributes.size() > 1 ) {\n\t\t\t\tthrow new FunctionArgumentException( \"Argument '\" + sqmPath.getNavigablePath()\n\t\t\t\t\t\t\t+ \"' of 'naturalid()' is a '\" + identifiableType.getTypeName()\n\t\t\t\t\t\t\t+ \"' and has a composite natural id\"","sourceCodeStart":3564,"sourceCodeEnd":3600,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java#L3564-L3600","documentation":"Error \"Path continuation from 'naturalid()' reference not yet implemented\" thrown in hibernate/hibernate-orm.","triggerScenarios":"The naturalid() function is misused: Path continuation from 'naturalid()' reference not yet implemented","commonSituations":"Calling naturalid() on entities without a @NaturalId, with a composite natural id, or continuing a path from it.","solutions":["Do not continue a path past a naturalid() reference; naturalid() must be the terminal step of the path. Rewrite the HQL so the path ends at naturalid(), or join/load the entity and navigate its attributes instead."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}