{"record":{"id":"903e6db350631420","repo":"hibernate/hibernate-orm","slug":"could-not-locate-getter-for-property-named-co","errorCode":null,"errorMessage":"Could not locate getter for property named [\" + containerJavaType.getName() + \"#\" + propertyName + \"]","messagePattern":"Could not locate getter for property named \\[\" \\+ containerJavaType\\.getName\\(\\) \\+ \"#\" \\+ propertyName \\+ \"\\]","errorType":"exception","errorClass":"PropertyAccessBuildingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/property/access/internal/PropertyAccessEnhancedImpl.java","lineNumber":68,"sourceCode":"\t\t\t\t\t\t? getAccessType( containerJavaType, propertyName )\n\t\t\t\t\t\t: classAccessType;\n\n\t\tswitch ( propertyAccessType ) {\n\t\t\tcase FIELD: {\n\t\t\t\tfinal var field = fieldOrNull( containerJavaType, propertyName );\n\t\t\t\tif ( field == null ) {\n\t\t\t\t\tthrow new PropertyAccessBuildingException(\n\t\t\t\t\t\t\t\"Could not locate field for property named [\" + containerJavaType.getName() + \"#\" + propertyName + \"]\"\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tgetter = new GetterFieldImpl( containerJavaType, propertyName, field );\n\t\t\t\tsetter = new EnhancedSetterImpl( containerJavaType, propertyName, field );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase PROPERTY: {\n\t\t\t\tfinal var getterMethod = getterMethodOrNull( containerJavaType, propertyName );\n\t\t\t\tif ( getterMethod == null ) {\n\t\t\t\t\tthrow new PropertyAccessBuildingException(\n\t\t\t\t\t\t\t\"Could not locate getter for property named [\" + containerJavaType.getName() + \"#\" + propertyName + \"]\"\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tgetter = propertyGetter( classAccessType, containerJavaType, propertyName, getterMethod );\n\t\t\t\tsetter = propertySetter( classAccessType, containerJavaType, propertyName, getterMethod.getReturnType() );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new PropertyAccessBuildingException(\n\t\t\t\t\t\t\"Invalid access type \" + propertyAccessType + \" for property named [\" + containerJavaType.getName() + \"#\" + propertyName + \"]\"\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static Getter propertyGetter(@Nullable AccessType classAccessType, Class<?> containerJavaType, String propertyName, Method getterMethod) {\n\t\tif ( classAccessType != null ) {\n\t\t\tfinal var explicitAccessType = getAccessType( containerJavaType, propertyName );","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/property/access/internal/PropertyAccessEnhancedImpl.java#L50-L86","documentation":"The PROPERTY branch of PropertyAccessEnhancedImpl: after resolving access type PROPERTY, it looks up the getter via getterMethodOrNull(containerJavaType, propertyName). A null getter throws PropertyAccessBuildingException 'Could not locate getter for property named [Class#property]' — the mapping expects a JavaBean getter that does not exist on the class.","triggerScenarios":"Access type resolves to PROPERTY (class-level @Access(PROPERTY) or annotation-driven inference) but containerJavaType declares no getter for propertyName — for example <property name=\"orderDate\"/> in orm.xml with only a field named orderDate and no getOrderDate().","commonSituations":"Renaming or deleting getters without updating XML mappings; Lombok annotation accidentally removed so the getter vanished; mappings written against an interface/DTO shape while applied to a class without the getter; field-only classes where access was globally set to property.","solutions":["Add the missing JavaBean getter (getOrderDate()) for the mapped property","Or switch that member to FIELD access with @Access(AccessType.FIELD) if the value is field-backed","Fix the property name in the mapping if it was a typo","Keep a SessionFactory bootstrap test in CI to catch mapping/property drift at build time"],"exampleFix":"// before\n@Entity @Access(AccessType.PROPERTY)\npublic class Order {\n    private LocalDate orderDate; // no getter\n}\n\n// after\n@Entity @Access(AccessType.PROPERTY)\npublic class Order {\n    private LocalDate orderDate;\n    public LocalDate getOrderDate() { return orderDate; }\n}","handlingStrategy":"validation","validationCode":"// Fail fast at startup: every property-mapped property needs a getter\ntry {\n    Order.class.getDeclaredMethod(\"getOrderDate\");\n} catch (NoSuchMethodException e) {\n    throw new IllegalStateException(\"Property access requires Order#getOrderDate()\", e);\n}","typeGuard":null,"tryCatchPattern":"try {\n    SessionFactory sf = metadata.buildSessionFactory();\n} catch (org.hibernate.property.access.internal.PropertyAccessBuildingException e) {\n    // expected getter missing: add it or switch the member to FIELD access\n}","preventionTips":["Keep Lombok/IDE-generated getters in place for property-mapped attributes","Set explicit @Access on members so inference cannot pick the wrong strategy","Bootstrap-test the SessionFactory in CI"],"tags":["hibernate","mapping","property-access","reflection","bootstrap"],"backgroundTag":"missing-property-mapping","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}