hibernate/hibernate-orm · error · HibernateException
Could not resolve PropertyAccess for attribute `%s#%s`
Error message
Could not resolve PropertyAccess for attribute `%s#%s`
What it means
Thrown while building the runtime model for a POJO entity (EntityRepresentationStrategyPojoStandard.makePropertyAccess) when no PropertyAccessStrategy can be found for one of the entity's mapped attributes. propertyAccessStrategy(...) consults the StrategySelector with the property and the mapped class; a null result - classically because the mapped class exposes neither a field nor a getter under the mapped attribute name - aborts bootstrap with the entity type and attribute named in the message.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/metamodel/internal/EntityRepresentationStrategyPojoStandard.java:314
);
}
catch (HibernateException he) {
CORE_LOGGER.unableToCreateProxyFactory( entityName, he );
return null;
}
return proxyFactory;
}
private ReflectionOptimizer resolveReflectionOptimizer(BytecodeProvider bytecodeProvider) {
return bytecodeProvider.getReflectionOptimizer( mappedJtd.getJavaTypeClass(), propertyAccessMap );
}
private PropertyAccess makePropertyAccess(Property bootAttributeDescriptor, StrategySelector strategySelector) {
final var mappedClass = mappedJtd.getJavaTypeClass();
final String descriptorName = bootAttributeDescriptor.getName();
final var strategy = propertyAccessStrategy( bootAttributeDescriptor, mappedClass, strategySelector );
if ( strategy == null ) {
throw new HibernateException(
String.format(
Locale.ROOT,
"Could not resolve PropertyAccess for attribute `%s#%s`",
mappedJtd.getTypeName(),
descriptorName
)
);
}
return strategy.buildPropertyAccess( mappedClass, descriptorName, true );
}
@Override
public RepresentationMode getMode() {
return RepresentationMode.POJO;
}
@Override
public ReflectionOptimizer getReflectionOptimizer() {View on GitHub (pinned to fad1729dce)
Solutions
- Compare the attribute name in the message with the entity class members; fix the mapping or add the missing field/getter
- Rebuild the project so mapping files and compiled classes stay in sync
- Check the access type in effect for the attribute (@Access on class/property, default from @Id placement) and provide the corresponding member
- Search the mapping sources for the exact attribute string to find the offending declaration
Example fix
// before
<class name="User" table="USERS">
<property name="e-mail" column="EMAIL"/> <!-- no such member -->
</class>
public class User { private String email; }
// after
<class name="User" table="USERS">
<property name="email" column="EMAIL"/>
</class> Defensive patterns
Strategy: validation
Validate before calling
// Validate mapped entity attribute names against class members before boot
for ( Map.Entry<Class<?>, Set<String>> e : mappedAttributesByClass().entrySet() ) {
for ( String attr : e.getValue() ) {
if ( !attributeAccessible(e.getKey(), attr) ) {
throw new IllegalStateException("Entity " + e.getKey() + " has no member for mapped attribute '" + attr + "'");
}
}
} Type guard
static boolean attributeAccessible(Class<?> c, String attr) {
try { c.getDeclaredField(attr); return true; } catch (NoSuchFieldException ignored) {}
try { c.getMethod("get" + Character.toUpperCase(attr.charAt(0)) + attr.substring(1)); return true; } catch (NoSuchMethodException ignored) {}
return false;
} Try / catch
try {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("pu");
}
catch ( org.hibernate.HibernateException e ) {
if ( e.getMessage() != null && e.getMessage().contains("Could not resolve PropertyAccess for attribute") ) {
// the message is `Entity#attribute` - reconcile mapping names with class members
throw new ConfigurationError("Attribute/mapping mismatch: " + e.getMessage(), e);
}
throw e;
} Prevention
- Rename entity members and their mapping declarations in the same commit
- Prefer annotations over XML so names live next to the fields
- Add a CI metadata test that boots the factory for every persistence unit
When it happens
Trigger: hbm.xml <property name="..."> naming a member that does not exist on the entity class (typo, rename, stale jar); @Access(PROPERTY) expected but the getter for an attribute is missing or non-public in a way the strategies reject; mixed access-type mappings where an attribute has no accessible member on the chosen side.
Common situations: Renaming entity getters without updating XML mappings; version skew between the domain jar and mapping resources on the classpath; code-generated mappings (freemarker/velocity templates) emitting wrong attribute names; Kotlin entities where the backing property is private without a getter.
Related errors
- Could not resolve PropertyAccess for attribute `%s#%s`
- Attribute was not a Map : ${collectionMemberType}
- Unable to create AttributeConverter instance
- Unable to build Hibernate SessionFactory [persistence unit:
- Could not locate field for property named [" + containerJava
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/11b73c929686205b.
Report an issue: GitHub.