hibernate/hibernate-orm · error · MemberResolutionException
Could not locate attribute member - %s (%s)
Error message
Could not locate attribute member - %s (%s)
What it means
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'.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/XmlProcessingHelper.java:53
public static AccessType inverse(AccessType accessType) {
return accessType == AccessType.FIELD ? AccessType.PROPERTY : AccessType.FIELD;
}
/**
* Find the member backing the named attribute
*/
public static MutableMemberDetails getAttributeMember(
String attributeName,
AccessType accessType,
MutableClassDetails classDetails) {
final MutableMemberDetails result = findAttributeMember(
attributeName,
accessType,
classDetails
);
if ( result == null ) {
throw new MemberResolutionException(
String.format(
"Could not locate attribute member - %s (%s)",
attributeName,
classDetails.getName()
)
);
}
return result;
}
/**
* Find the member backing the named attribute
*/
public static MutableMemberDetails findAttributeMember(
String attributeName,
AccessType accessType,
MutableClassDetails classDetails) {
if ( accessType == AccessType.PROPERTY ) {View on GitHub (pinned to fad1729dce)
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.
Example fix
<!-- before: no member named 'fone' on Order --> <property name="fone" type="string" column="PHONE"/> <!-- after: name matches the Java field 'phone' --> <property name="phone" type="string" column="PHONE"/>
Defensive patterns
Strategy: validation
Validate before calling
boolean memberExists(Class<?> clazz, String name, String access) {
if ( "field".equals( access ) ) {
for ( Class<?> c = clazz; c != null; c = c.getSuperclass() ) {
try { c.getDeclaredField( name ); return true; }
catch ( NoSuchFieldException ignored ) { }
}
return false;
}
String suffix = Character.toUpperCase( name.charAt( 0 ) ) + name.substring( 1 );
try {
clazz.getMethod( "get" + suffix ); return true;
}
catch ( NoSuchMethodException e ) {
try { clazz.getMethod( "is" + suffix ); return true; }
catch ( NoSuchMethodException e2 ) { return false; }
}
}
// run before building the SessionFactory, for every attribute element in the XML:
// if ( !memberExists( mappedClass, attrName, accessType ) ) -> fail with a clear message Try / catch
try {
Metadata metadata = new MetadataSources( registry ).addFile( "mapping.hbm.xml" ).buildMetadata();
}
catch ( MemberResolutionException e ) {
// message: "Could not locate attribute member - <name> (<class>)"
throw new IllegalStateException( "Stale XML mapping: " + e.getMessage(), e );
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Identifier property '" + getPath( holder, data ) + "' cannot
- Class or package level '@NamedQuery' annotation must specify
- Class or package level '@NamedStatement' annotation must spe
- Class or package level '@NamedNativeQuery' annotation must s
- Class or package level '@NamedStoredProcedureQuery' annotati
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/a7bed8b97e00a042.
Report an issue: GitHub.