{"record":{"id":"a01d31e0f00d707c","repo":"hibernate/hibernate-orm","slug":"attribute-is-not-of-type","errorCode":null,"errorMessage":"Attribute '{}' is not of type '{}'","messagePattern":"Attribute '(.+?)' is not of type '(.+?)'","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/restriction/NamedPathElement.java","lineNumber":28,"sourceCode":"\n/**\n * A non-root element of a {@link Path}, using a stringly-typed\n * attribute reference.\n *\n * @author Gavin King\n */\nrecord NamedPathElement<X, U, V>(Path<? super X, U> parent, String attributeName, Class<V> attributeType)\n\t\timplements Path<X, V> {\n\t@Override\n\tpublic Class<V> getType() {\n\t\treturn attributeType;\n\t}\n\n\t@Override\n\tpublic jakarta.persistence.criteria.Path<V> path(Root<? extends X> root) {\n\t\tfinal jakarta.persistence.criteria.Path<V> path = parent.path( root ).get( attributeName );\n\t\tif ( !attributeType.isAssignableFrom( path.getJavaType() ) ) {\n\t\t\tthrow new IllegalArgumentException( \"Attribute '\" + attributeName\n\t\t\t\t\t\t\t\t\t\t\t\t+ \"' is not of type '\" + attributeType.getName() + \"'\" );\n\t\t}\n\t\treturn path;\n\t}\n\n\t@Override\n\tpublic FetchParent<?, V> fetch(Root<? extends X> root) {\n\t\treturn parent.fetch( root ).fetch( attributeName, JoinType.LEFT );\n\t}\n}\n","sourceCodeStart":10,"sourceCodeEnd":39,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/restriction/NamedPathElement.java#L10-L39","documentation":"Error \"Attribute '{}' is not of type '{}'\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A range/restriction references an attribute of the wrong kind or type: Attribute '<value>' is not of type '<value>'","commonSituations":"Defining NamedAttributeRange/NamedPathElement over plural attributes or attributes of a mismatched type.","solutions":["The attribute is not of the required type. Check the attribute name and the expected type in the restriction."],"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"}