hibernate/hibernate-orm · error · IllegalArgumentException

Attribute '{}' is not singular

Error message

Attribute '{}' is not singular

What it means

Error "Attribute '{}' is not singular" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/query/restriction/NamedAttributeRange.java:38

 * @param <U> The attribute type
 *
 * @author Gavin King
 */
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)

Solutions

  1. The attribute is plural (collection-valued) but a singular attribute is required. Restrict on a singular attribute.

When it happens

Trigger: A range/restriction references an attribute of the wrong kind or type: Attribute '<value>' is not singular

Common situations: Defining NamedAttributeRange/NamedPathElement over plural attributes or attributes of a mismatched type.


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/55cc134e5d360322. Report an issue: GitHub.