{"record":{"id":"62e0d47933017836","repo":"hibernate/hibernate-orm","slug":"could-not-resolve-propertyaccess-for-attribute-s","errorCode":null,"errorMessage":"Could not resolve PropertyAccess for attribute `%s#%s`","messagePattern":"Could not resolve PropertyAccess for attribute `(.+?)#(.+?)`","errorType":"exception","errorClass":"HibernateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/metamodel/internal/EmbeddableRepresentationStrategyPojo.java","lineNumber":185,"sourceCode":"\t\t}\n\t\telse {\n\t\t\treturn new EmbeddableInstantiatorPojoStandard( embeddableClass, runtimeDescriptorAccess );\n\t\t}\n\t}\n\n\tprivate static ProxyFactoryFactory getProxyFactoryFactory(RuntimeModelCreationContext creationContext) {\n\t\treturn creationContext.getServiceRegistry()\n\t\t\t\t.requireService( ProxyFactoryFactory.class );\n\t}\n\n\tprivate PropertyAccess buildPropertyAccess(\n\t\t\tProperty property,\n\t\t\tClass<?> embeddableClass,\n\t\t\tboolean requireSetters,\n\t\t\tStrategySelector strategySelector) {\n\t\tfinal var strategy = propertyAccessStrategy( property, embeddableClass, strategySelector );\n\t\tif ( strategy == null ) {\n\t\t\tthrow new HibernateException(\n\t\t\t\t\tString.format(\n\t\t\t\t\t\t\tLocale.ROOT,\n\t\t\t\t\t\t\t\"Could not resolve PropertyAccess for attribute `%s#%s`\",\n\t\t\t\t\t\t\tgetEmbeddableJavaType().getTypeName(),\n\t\t\t\t\t\t\tproperty.getName()\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\treturn strategy.buildPropertyAccess( embeddableClass, property.getName(), requireSetters );\n\t}\n\n\tprivate static ReflectionOptimizer buildReflectionOptimizer(\n\t\t\tComponent bootDescriptor,\n\t\t\tboolean hasCustomAccessors,\n\t\t\tPropertyAccess[] propertyAccesses,\n\t\t\tRuntimeModelCreationContext creationContext) {\n\t\tif ( !hasCustomAccessors\n\t\t\t\t&& bootDescriptor.getCustomInstantiator() == null","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/metamodel/internal/EmbeddableRepresentationStrategyPojo.java#L167-L203","documentation":"Thrown while Hibernate builds the runtime metamodel for an embeddable (EmbeddableRepresentationStrategyPojo.buildPropertyAccess) when no PropertyAccessStrategy can be resolved for a mapped attribute. propertyAccessStrategy(...) asks the StrategySelector for a strategy able to access the property on the embeddable class; when it returns null - typically because the class has neither a field nor a getter matching the mapped attribute name - this HibernateException aborts SessionFactory creation and names the embeddable type and the offending attribute.","triggerScenarios":"XML <component> or <properties> mapping referencing a property name that does not exist on the embeddable class (renamed field, typo); annotation mappings where @AttributeOverrides/@AssociationOverride renames diverge from the actual Java member; embeddable class compiled without the field (stale jar on classpath) while the mapping metadata still lists it; access type mismatch where the expected getter is missing.","commonSituations":"Renaming embeddable fields without updating hbm.xml files; deployment mixing an old domain jar with new mapping files; copy-pasting @Embedded mappings between embeddable classes with different member names; Kotlin embeddables where the property is private with no public getter.","solutions":["Match the message's attribute name against the embeddable class members - add the missing field/getter or fix the name in the mapping","If the field was renamed, update the XML/annotation accordingly (or use @AttributeOverride to align names)","Clean and rebuild so the compiled embeddable class and the mapping metadata come from the same source version","Ensure getters exist (or switch the mapping to field access) for the reported attribute"],"exampleFix":"// before\npublic class Address {\n    private String streetName;   // mapping says 'street'\n}\n<component name=\"address\">\n    <property name=\"street\" column=\"STREET\"/>\n</component>\n\n// after - align the mapping with the field\n<component name=\"address\">\n    <property name=\"streetName\" column=\"STREET\"/>\n</component>","handlingStrategy":"validation","validationCode":"// Verify every mapped attribute of the embeddable resolves to a field or getter\nstatic void checkPropertyAccess(Class<?> embeddable, List<String> mappedAttributes) {\n    for ( String attr : mappedAttributes ) {\n        boolean hasField = Arrays.stream(embeddable.getDeclaredFields()).anyMatch(f -> f.getName().equals(attr));\n        boolean hasGetter = false;\n        try { embeddable.getMethod(\"get\" + Character.toUpperCase(attr.charAt(0)) + attr.substring(1)); hasGetter = true; }\n        catch (NoSuchMethodException ignored) {}\n        if ( !hasField && !hasGetter ) throw new IllegalStateException(\"No member for attribute \" + attr + \" on \" + embeddable);\n    }\n}","typeGuard":"static boolean attributeAccessible(Class<?> c, String attr) {\n    try { c.getDeclaredField(attr); return true; } catch (NoSuchFieldException ignored) {}\n    try { c.getMethod(\"get\" + Character.toUpperCase(attr.charAt(0)) + attr.substring(1)); return true; } catch (NoSuchMethodException ignored) {}\n    return false;\n}","tryCatchPattern":"try {\n    EntityManagerFactory emf = Persistence.createEntityManagerFactory(\"pu\");\n}\ncatch ( org.hibernate.HibernateException e ) {\n    if ( e.getMessage() != null && e.getMessage().contains(\"Could not resolve PropertyAccess\") ) {\n        // message embeds `Type#attribute` - fix the mapping/class mismatch it names\n        throw new ConfigurationError(\"Mapping/class mismatch: \" + e.getMessage(), e);\n    }\n    throw e;\n}","preventionTips":["Single-source attribute names: generate XML from annotations or the class, not by hand","Rebuild the whole project together so mapping files and compiled classes never skew","Grep all mapping files for an attribute name before renaming any embeddable field"],"tags":["hibernate","jpa","embeddable","property-access","mapping","bootstrap"],"backgroundTag":"property-access-resolution-failed","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}