{"record":{"id":"596873ad75eb6933","repo":"hibernate/hibernate-orm","slug":"invalid-access-type-propertyaccesstype-for","errorCode":null,"errorMessage":"Invalid access type \" + propertyAccessType + \" for property named [\" + containerJavaType.getName() + \"#\" + propertyName + \"]","messagePattern":"Invalid access type \" \\+ propertyAccessType \\+ \" 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":77,"sourceCode":"\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 );\n\t\t\tif ( explicitAccessType == AccessType.FIELD ) {\n\t\t\t\t// We need to default to FIELD unless we have an explicit AccessType\n\t\t\t\t// to avoid unnecessary initializations\n\t\t\t\treturn new EnhancedGetterFieldImpl( containerJavaType, propertyName,\n\t\t\t\t\t\tfindField( containerJavaType, propertyName ), getterMethod );\n\t\t\t}\n\t\t}\n\t\t// when classAccessType is null, know PROPERTY is the explicit access type\n\t\treturn new GetterMethodImpl( containerJavaType, propertyName, getterMethod );","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/property/access/internal/PropertyAccessEnhancedImpl.java#L59-L95","documentation":"The access-type switch in PropertyAccessEnhancedImpl handles FIELD and PROPERTY only; any other resolved AccessType reaches the default branch and throws PropertyAccessBuildingException 'Invalid access type X for property named [Class#property]'. In practice this means access resolution produced a value the builder does not understand — a misconfigured access setting or a constant from mismatched jars.","triggerScenarios":"hibernate.default_access or an XML access attribute set to something other than field/property; an @Access resolving against a custom or unknown AccessType constant, typically from mixed Hibernate versions on the classpath.","commonSituations":"Typos in the global access configuration; two different hibernate-core versions mixed via transitive dependencies; custom forks adding AccessType values the property-access builder was never taught.","solutions":["Set the access type to a supported value: field or property","Remove the custom/global access override and let Hibernate infer per member","Check for mixed hibernate-core versions (mvn dependency:tree / gradle dependencies) and align to one version"],"exampleFix":"// before (persistence.xml)\n<property name=\"hibernate.default_access\" value=\"recod\"/> <!-- typo/unsupported -->\n\n// after\n<property name=\"hibernate.default_access\" value=\"field\"/>","handlingStrategy":"try-catch","validationCode":"Set<String> allowed = Set.of(\"field\", \"property\");\nif (!allowed.contains(configuredAccess)) {\n    throw new IllegalStateException(\"Unsupported access type: \" + configuredAccess);\n}","typeGuard":null,"tryCatchPattern":"try {\n    SessionFactory sf = metadata.buildSessionFactory();\n} catch (org.hibernate.property.access.internal.PropertyAccessBuildingException e) {\n    if (e.getMessage().contains(\"Invalid access type\")) {\n        // fix the global/member access configuration to field or property\n    }\n}","preventionTips":["Only use field or property as access values in configuration","Align all modules on one hibernate-core version to avoid enum constant mismatches","Validate configuration values at application startup"],"tags":["hibernate","mapping","configuration","property-access","bootstrap"],"backgroundTag":"invalid-access-type","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}