{"record":{"id":"e2945e7075680f5e","repo":"hibernate/hibernate-orm","slug":"unknown-attribute","errorCode":null,"errorMessage":"Unknown attribute: {}","messagePattern":"Unknown attribute: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/graph/internal/GraphImpl.java","lineNumber":95,"sourceCode":"\n\n\t@Override\n\t@Nonnull\n\tpublic List<AttributeNodeImplementor<?,?,?>> getAttributeNodeList() {\n\t\treturn attributeNodes == null ? emptyList() : new ArrayList<>( attributeNodes.values() );\n\t}\n\n\t@Override\n\t@Nonnull\n\tpublic Map<PersistentAttribute<? super J, ?>, AttributeNodeImplementor<?,?,?>> getNodes() {\n\t\treturn attributeNodes == null ? emptyMap() : new HashMap<>( attributeNodes );\n\t}\n\n\t@Override\n\tpublic boolean hasAttributeNode(@Nonnull String attributeName) {\n\t\tfinal var attribute = findAttributeInSupertypes( attributeName );\n\t\tif ( attribute == null ) {\n\t\t\tthrow new IllegalArgumentException( \"Unknown attribute: \" + attributeName );\n\t\t}\n\t\treturn attributeNodes != null\n\t\t\t&& attributeNodes.containsKey( attribute );\n\t}\n\n\t@Override\n\tpublic boolean hasAttributeNode(@Nonnull Attribute<? super J, ?> attribute) {\n\t\treturn attributeNodes != null\n\t\t\t&& attributeNodes.containsKey( (PersistentAttribute<? super J, ?>) attribute );\n\t}\n\n\t@Override\n\t@Nonnull\n\tpublic <Y> AttributeNodeImplementor<Y,?,?> getAttributeNode(@Nonnull String attributeName) {\n\t\tfinal var attribute = findAttributeInSupertypes( attributeName );\n\t\tif ( attribute == null ) {\n\t\t\tthrow new IllegalArgumentException( \"Unknown attribute: \" + attributeName );\n\t\t}","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/graph/internal/GraphImpl.java#L77-L113","documentation":"GraphImpl.hasAttributeNode(String) first resolves the name via findAttributeInSupertypes (the graphed type's attributes plus inherited ones) and throws IllegalArgumentException('Unknown attribute: ...') when no such attribute exists — it does not return false for unknown names, unlike the Attribute-based overload. The boolean answer only distinguishes node presence for names that are real attributes.","triggerScenarios":"Calling hasAttributeNode(name) with a typo, a database column name instead of the property name, a @Transient field, or an attribute that exists only on a subclass (accessible via treated subgraphs) rather than on the graphed type.","commonSituations":"Dynamic graph utilities that probe by string; using column names where attribute names are expected; mappings where the attribute lives in a @MappedSuperclass or a different hierarchy level than assumed.","solutions":["Pass the JPA attribute name (field/property name), not the column name","Validate the name against the metamodel first (managedType.getAttributes()) before probing the graph","Prefer the Attribute-based overload hasAttributeNode(Attribute) when you hold metamodel references","For pure existence probing of arbitrary strings, wrap the call and treat IllegalArgumentException as 'false'"],"exampleFix":"// before\nboolean has = graph.hasAttributeNode(\"cust_name\"); // column name → IllegalArgumentException\n\n// after\nboolean has = graph.hasAttributeNode(\"customer\");  // JPA attribute name","handlingStrategy":"validation","validationCode":"// Safe existence probe: validate the name against the metamodel, then check node presence\nstatic boolean hasNodeSafely(EntityGraph<?> graph, Metamodel mm, Class<?> type, String attrName) {\n    try {\n        mm.managedType(type).getAttribute(attrName);   // throws IllegalArgumentException if unknown\n    }\n    catch (IllegalArgumentException unknown) {\n        return false;\n    }\n    return graph.getAttributeNodes().stream()\n            .map(AttributeNode::getAttributeName)\n            .anyMatch(attrName::equals);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use metamodel attribute names, not column names, in graph code","Prefer the Attribute-based overloads of graph methods","Validate names against managedType.getAttributes() when building graphs dynamically"],"tags":["hibernate","entity-graph","attribute-name","metamodel","jpa"],"backgroundTag":"unknown-entity-attribute","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}