{"record":{"id":"a820c40a5d4dc507","repo":"hibernate/hibernate-orm","slug":"argument-of-version-does-not-resolve-to-a","errorCode":null,"errorMessage":"Argument '{}' of 'version()' does not resolve to an entity type","messagePattern":"Argument '(.+?)' of 'version\\(\\)' does not resolve to an entity type","errorType":"exception","errorClass":"FunctionArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java","lineNumber":3569,"sourceCode":"\tpublic SqmPath<?> visitEntityVersionReference(HqlParser.EntityVersionReferenceContext ctx) {\n\t\treturn handleVersionPath( consumeDomainPath( ctx.path() ) );\n\t}\n\n\t@Nonnull\n\tprivate static <U> SqmPath<?> handleVersionPath(SqmPath<U> sqmPath) {\n\t\tif ( sqmPath.getReferencedPathSource().getPathType()\n\t\t\t\tinstanceof AbstractIdentifiableType<U> identifiableType ) {\n\t\t\tif ( !identifiableType.hasVersionAttribute() ) {\n\t\t\t\tthrow new FunctionArgumentException( \"Argument '\" + sqmPath.getNavigablePath()\n\t\t\t\t\t\t\t+ \"' of 'version()' is a '\" + identifiableType.getTypeName()\n\t\t\t\t\t\t\t+ \"' and does not have a '@Version' attribute\" );\n\t\t\t}\n\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) {","sourceCodeStart":3551,"sourceCodeEnd":3587,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java#L3551-L3587","documentation":"Error \"Argument '{}' of 'version()' does not resolve to an entity type\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A name/path expected to denote an entity type does not: Argument '<value>' of 'version()' does not resolve to an entity type","commonSituations":"Passing non-entity arguments to version()/naturalid(), or a TREAT target / entity name that is not a mapped entity; commonly a typo or unmapped class.","solutions":["Pass an entity type (entity name or entity-valued path) as the argument to version(); the argument currently resolves to a non-entity expression. Check that the path used in version(...) refers to a mapped entity."],"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"}