hibernate/hibernate-orm · error · PropertyAccessBuildingException

Invalid access type " + propertyAccessType + " for property

Error message

Invalid access type " + propertyAccessType + " for property named [" + containerJavaType.getName() + "#" + propertyName + "]

What it means

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.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/property/access/internal/PropertyAccessEnhancedImpl.java:77

					);
				}
				getter = new GetterFieldImpl( containerJavaType, propertyName, field );
				setter = new EnhancedSetterImpl( containerJavaType, propertyName, field );
				break;
			}
			case PROPERTY: {
				final var getterMethod = getterMethodOrNull( containerJavaType, propertyName );
				if ( getterMethod == null ) {
					throw new PropertyAccessBuildingException(
							"Could not locate getter for property named [" + containerJavaType.getName() + "#" + propertyName + "]"
					);
				}
				getter = propertyGetter( classAccessType, containerJavaType, propertyName, getterMethod );
				setter = propertySetter( classAccessType, containerJavaType, propertyName, getterMethod.getReturnType() );
				break;
			}
			default: {
				throw new PropertyAccessBuildingException(
						"Invalid access type " + propertyAccessType + " for property named [" + containerJavaType.getName() + "#" + propertyName + "]"
				);
			}
		}
	}

	private static Getter propertyGetter(@Nullable AccessType classAccessType, Class<?> containerJavaType, String propertyName, Method getterMethod) {
		if ( classAccessType != null ) {
			final var explicitAccessType = getAccessType( containerJavaType, propertyName );
			if ( explicitAccessType == AccessType.FIELD ) {
				// We need to default to FIELD unless we have an explicit AccessType
				// to avoid unnecessary initializations
				return new EnhancedGetterFieldImpl( containerJavaType, propertyName,
						findField( containerJavaType, propertyName ), getterMethod );
			}
		}
		// when classAccessType is null, know PROPERTY is the explicit access type
		return new GetterMethodImpl( containerJavaType, propertyName, getterMethod );

View on GitHub (pinned to fad1729dce)

Solutions

  1. Set the access type to a supported value: field or property
  2. Remove the custom/global access override and let Hibernate infer per member
  3. Check for mixed hibernate-core versions (mvn dependency:tree / gradle dependencies) and align to one version

Example fix

// before (persistence.xml)
<property name="hibernate.default_access" value="recod"/> <!-- typo/unsupported -->

// after
<property name="hibernate.default_access" value="field"/>
Defensive patterns

Strategy: try-catch

Validate before calling

Set<String> allowed = Set.of("field", "property");
if (!allowed.contains(configuredAccess)) {
    throw new IllegalStateException("Unsupported access type: " + configuredAccess);
}

Try / catch

try {
    SessionFactory sf = metadata.buildSessionFactory();
} catch (org.hibernate.property.access.internal.PropertyAccessBuildingException e) {
    if (e.getMessage().contains("Invalid access type")) {
        // fix the global/member access configuration to field or property
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/596873ad75eb6933. Report an issue: GitHub.