{"record":{"id":"55cc134e5d360322","repo":"hibernate/hibernate-orm","slug":"attribute-is-not-singular","errorCode":null,"errorMessage":"Attribute '{}' is not singular","messagePattern":"Attribute '(.+?)' is not singular","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/query/restriction/NamedAttributeRange.java","lineNumber":38,"sourceCode":" * @param <U> The attribute type\n *\n * @author Gavin King\n */\nrecord 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":20,"sourceCodeEnd":48,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/query/restriction/NamedAttributeRange.java#L20-L48","documentation":"Error \"Attribute '{}' is not singular\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A range/restriction references an attribute of the wrong kind or type: Attribute '<value>' is not singular","commonSituations":"Defining NamedAttributeRange/NamedPathElement over plural attributes or attributes of a mismatched type.","solutions":["The attribute is plural (collection-valued) but a singular attribute is required. Restrict on a singular attribute."],"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"}