hibernate/hibernate-orm · error · HibernateException

cannot find an accessor

Error message

cannot find an accessor [%s] on type [%s]

What it means

Could not locate the getter or setter method on the class for one of the property accessor names supplied to the reflection optimizer. The named accessor does not exist on the type; usually a mismatch between mapped property accessors and the actual class.

Solutions

  1. Ensure every persistent property has a matching getter/setter pair with consistent types; check for misnamed accessors after refactoring.

Example fix

Ensure every persistent property has a matching getter/setter pair with consistent types; check for misnamed accessors after refactoring.
Defensive patterns

Strategy: validation

When it happens

Trigger: Bytecode enhancement, proxy creation, or lazy interception is applied to an incompatible class or configuration.

Common situations: Build-time enhancement with module-system restrictions, mismatched Hibernate versions between build and runtime, or hibernate.bytecode.provider=none with a model that needs proxies.


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

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/bytecode/internal/bytebuddy/BytecodeProviderImpl.java:399

		if ( setterNames.length != length || getterNames.length != length ) {
			throw new HibernateException( "bad number of accessors" );
		}

		final Class<?>[] getParam = new Class[0];
		for ( int i = 0; i < length; i++ ) {
			if ( getterNames[i] != null ) {
				final Method getter = findAccessor( clazz, getterNames[i], getParam );
				if ( getter.getReturnType() != types[i] ) {
					throw new HibernateException( "wrong return type: " + getterNames[i] );
				}

				getters[i] = getter;
			}

			if ( setterNames[i] != null ) {
				setters[i] = ReflectHelper.setterMethodOrNullBySetterName( clazz, setterNames[i], types[i] );
				if ( setters[i] == null ) {
					throw new HibernateException(
							String.format(
									"cannot find an accessor [%s] on type [%s]",
									setterNames[i],
									clazz.getName()
							)
					);
				}
				else if ( isPrivate( setters[i].getModifiers() ) ) {
					throw new PrivateAccessorException( "private accessor [" + setterNames[i] + "]" );
				}
			}
		}
	}

	private static void findAccessors(
			Class<?> clazz,
			Map<String, PropertyAccess> propertyAccessMap,
			Member[] getters,

View on GitHub (pinned to fad1729dce)