hibernate/hibernate-orm · error · IllegalArgumentException
Attribute ' ' is not assignable to range of type
Error message
Attribute '{}' is not assignable to range of type '{}' What it means
Guard in NamedAttributeRange.toPredicate: the named attribute's Java type is not assignable to the type parameter of the Range being applied, so the predicate could not be type-safe.
Solutions
- The attribute type is not assignable to the range type. Use an attribute whose type matches the range bounds.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: A parameter is bound with a value or type incompatible with its declared type: Attribute '<value>' is not assignable to range of type '<value>'
Common situations: Binding a Java value whose type does not match the parameter's declared Hibernate/Java type, or passing a mismatched Class/TypedParameterValue to setParameter().
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/b3b080cba2c108e6.
Report an issue: GitHub.
Appendix: source
Thrown at hibernate-core/src/main/java/org/hibernate/query/restriction/NamedAttributeRange.java:42
record NamedAttributeRange<X, U>(Class<X> entity, String attributeName, Range<U> range) implements Restriction<X> {
@Override
public Restriction<X> negated() {
return new Negation<>( this );
}
@Override
public Predicate toPredicate(Root<? extends X> root, CriteriaBuilder builder) {
final EntityType<? extends X> entityType = root.getModel();
if ( !entity.isAssignableFrom( entityType.getJavaType() ) ) {
throw new IllegalArgumentException( "Root entity is not a subtype of '" + entity.getTypeName() + "'" );
}
final Attribute<?, ?> attribute = entityType.getAttribute( attributeName );
if ( !(attribute instanceof SingularAttribute) ) {
throw new IllegalArgumentException( "Attribute '" + attributeName + "' is not singular" );
}
final Class<? extends U> rangeType = range.getType();
if ( rangeType != null && !rangeType.isAssignableFrom( attribute.getJavaType() ) ) {
throw new IllegalArgumentException( "Attribute '" + attributeName
+ "' is not assignable to range of type '" + rangeType.getName() + "'" );
}
return range.toPredicate( root.get( attributeName ), builder );
}
}
View on GitHub (pinned to fad1729dce)