{"record":{"id":"d0f564687bd7e246","repo":"hibernate/hibernate-orm","slug":"argument-of-version-is-a-and-does-no","errorCode":null,"errorMessage":"Argument '{}' of 'version()' is a '{}' and does not have a '@Version' attribute","messagePattern":"Argument '(.+?)' of 'version\\(\\)' is a '(.+?)' and does not have a '@Version' attribute","errorType":"exception","errorClass":"FunctionArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java","lineNumber":3560,"sourceCode":"\t\t}\n\t}\n\n\t@Override\n\tpublic SqmExpression<?> visitEntityVersionExpression(HqlParser.EntityVersionExpressionContext ctx) {\n\t\treturn visitEntityVersionReference( ctx.entityVersionReference() );\n\t}\n\n\t@Override\n\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","sourceCodeStart":3542,"sourceCodeEnd":3578,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java#L3542-L3578","documentation":"Error \"Argument '{}' of 'version()' is a '{}' and does not have a '@Version' attribute\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A runtime precondition of the Hibernate API is violated.","commonSituations":"Occurs when application code or configuration does not satisfy the documented contract of the API being called.","solutions":["Pass an entity that declares a @Version attribute to version().","Add a @Version property to the entity if optimistic locking is needed."],"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"}