{"record":{"id":"b3b080cba2c108e6","repo":"hibernate/hibernate-orm","slug":"attribute-is-not-assignable-to-range-of-type","errorCode":null,"errorMessage":"Attribute '{}' is not assignable to range of type '{}'","messagePattern":"Attribute '(.+?)' is not assignable to range of type '(.+?)'","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/restriction/NamedAttributeRange.java","lineNumber":42,"sourceCode":"record NamedAttributeRange<X, U>(Class<X> entity, String attributeName, Range<U> range) implements Restriction<X> {\n\t@Override\n\tpublic Restriction<X> negated() {\n\t\treturn new Negation<>( this );\n\t}\n\n\t@Override\n\tpublic Predicate toPredicate(Root<? extends X> root, CriteriaBuilder builder) {\n\t\tfinal EntityType<? extends X> entityType = root.getModel();\n\t\tif ( !entity.isAssignableFrom( entityType.getJavaType() ) ) {\n\t\t\tthrow new IllegalArgumentException( \"Root entity is not a subtype of '\" + entity.getTypeName() + \"'\" );\n\t\t}\n\t\tfinal Attribute<?, ?> attribute = entityType.getAttribute( attributeName );\n\t\tif ( !(attribute instanceof SingularAttribute) ) {\n\t\t\tthrow new IllegalArgumentException( \"Attribute '\" + attributeName + \"' is not singular\" );\n\t\t}\n\t\tfinal Class<? extends U> rangeType = range.getType();\n\t\tif ( rangeType != null && !rangeType.isAssignableFrom( attribute.getJavaType() ) ) {\n\t\t\tthrow new IllegalArgumentException( \"Attribute '\" + attributeName\n\t\t\t\t\t\t\t\t\t\t\t\t+ \"' is not assignable to range of type '\" + rangeType.getName() + \"'\" );\n\t\t}\n\t\treturn range.toPredicate( root.get( attributeName ), builder );\n\t}\n}\n","sourceCodeStart":24,"sourceCodeEnd":48,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/restriction/NamedAttributeRange.java#L24-L48","documentation":"Error \"Attribute '{}' is not assignable to range of type '{}'\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A parameter is bound with a value or type incompatible with its declared type: Attribute '<value>' is not assignable to range of type '<value>'","commonSituations":"Binding a Java value whose type does not match the parameter's declared Hibernate/Java type, or passing a mismatched Class/TypedParameterValue to setParameter().","solutions":["The attribute type is not assignable to the range type. Use an attribute whose type matches the range bounds."],"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"}