{"record":{"id":"a7bed8b97e00a042","repo":"hibernate/hibernate-orm","slug":"could-not-locate-attribute-member-s-s","errorCode":null,"errorMessage":"Could not locate attribute member - %s (%s)","messagePattern":"Could not locate attribute member - (.+?) \\((.+?)\\)","errorType":"exception","errorClass":"MemberResolutionException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/XmlProcessingHelper.java","lineNumber":53,"sourceCode":"\n\tpublic static AccessType inverse(AccessType accessType) {\n\t\treturn accessType == AccessType.FIELD ? AccessType.PROPERTY : AccessType.FIELD;\n\t}\n\n\t/**\n\t * Find the member backing the named attribute\n\t */\n\tpublic static MutableMemberDetails getAttributeMember(\n\t\t\tString attributeName,\n\t\t\tAccessType accessType,\n\t\t\tMutableClassDetails classDetails) {\n\t\tfinal MutableMemberDetails result = findAttributeMember(\n\t\t\t\tattributeName,\n\t\t\t\taccessType,\n\t\t\t\tclassDetails\n\t\t);\n\t\tif ( result == null ) {\n\t\t\tthrow new MemberResolutionException(\n\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\"Could not locate attribute member - %s (%s)\",\n\t\t\t\t\t\t\tattributeName,\n\t\t\t\t\t\t\tclassDetails.getName()\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Find the member backing the named attribute\n\t */\n\tpublic static MutableMemberDetails findAttributeMember(\n\t\t\tString attributeName,\n\t\t\tAccessType accessType,\n\t\t\tMutableClassDetails classDetails) {\n\t\tif ( accessType == AccessType.PROPERTY ) {","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/XmlProcessingHelper.java#L35-L71","documentation":"Thrown by Hibernate's XML mapping processor when an attribute referenced in an hbm.xml/orm.xml mapping has no backing field or property on the mapped class. XmlProcessingHelper.getAttributeMember() delegates to findAttributeMember(attributeName, accessType, classDetails) and throws MemberResolutionException when that lookup returns null. The lookup matches both the name and the declared access type (field vs property), so a member that exists with the wrong access type is still 'not found'.","triggerScenarios":"An XML mapping element like <property name=\"fone\"/> while the Java class declares 'phone'; access=\"field\" on the mapping while the class only exposes a getter (property access); an attribute listed on a subclass mapping but actually declared on a class not part of the mapped hierarchy; rename of a Java field without updating the XML.","commonSituations":"Refactoring renames fields but hbm.xml/orm.xml is not regenerated; mapping files copied between entities as templates; mixing JPA annotation access (field) with XML mapping of property access; mapped-superclass members referenced from the wrong class mapping.","solutions":["Correct the name attribute in the XML so it exactly matches the Java field or property name (case-sensitive).","Check the access type: if the mapping says access=\"field\" the member must be an actual field; if access=\"property\" a getter must exist.","Verify the member is declared on the exact class named in the mapping (or a proper superclass/mapped-superclass in that hierarchy), not a sibling class.","If the attribute was intentionally removed, delete the stale XML element instead of leaving it."],"exampleFix":"<!-- before: no member named 'fone' on Order -->\n<property name=\"fone\" type=\"string\" column=\"PHONE\"/>\n\n<!-- after: name matches the Java field 'phone' -->\n<property name=\"phone\" type=\"string\" column=\"PHONE\"/>","handlingStrategy":"validation","validationCode":"boolean memberExists(Class<?> clazz, String name, String access) {\n    if ( \"field\".equals( access ) ) {\n        for ( Class<?> c = clazz; c != null; c = c.getSuperclass() ) {\n            try { c.getDeclaredField( name ); return true; }\n            catch ( NoSuchFieldException ignored ) { }\n        }\n        return false;\n    }\n    String suffix = Character.toUpperCase( name.charAt( 0 ) ) + name.substring( 1 );\n    try {\n        clazz.getMethod( \"get\" + suffix ); return true;\n    }\n    catch ( NoSuchMethodException e ) {\n        try { clazz.getMethod( \"is\" + suffix ); return true; }\n        catch ( NoSuchMethodException e2 ) { return false; }\n    }\n}\n// run before building the SessionFactory, for every attribute element in the XML:\n// if ( !memberExists( mappedClass, attrName, accessType ) ) -> fail with a clear message","typeGuard":null,"tryCatchPattern":"try {\n    Metadata metadata = new MetadataSources( registry ).addFile( \"mapping.hbm.xml\" ).buildMetadata();\n}\ncatch ( MemberResolutionException e ) {\n    // message: \"Could not locate attribute member - <name> (<class>)\"\n    throw new IllegalStateException( \"Stale XML mapping: \" + e.getMessage(), e );\n}","preventionTips":["Treat hbm.xml/orm.xml attribute names as compile-time-coupled to Java members; grep the XML for a member name before renaming the Java side.","Add a bootstrap-time integration test that builds the SessionFactory for every mapping file so typos fail the build, not production.","Keep access type consistent between annotations and XML for the same class."],"tags":["hibernate","xml-mapping","orm","attribute-resolution","boot"],"backgroundTag":"mapping-attribute-not-found","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}