hibernate/hibernate-orm · error · IllegalArgumentException

Referenced field '${fieldName}' of class '${className}' does

Error message

Referenced field '${fieldName}' of class '${className}' does not exist

What it means

Error "Referenced field '${fieldName}' of class '${className}' does not exist" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java:391

		try {
			final var referencedField = getJavaField( className, fieldName );
			if ( referencedField != null ) {
				return getTypeConfiguration().getJavaTypeRegistry()
						.resolveDescriptor( referencedField.getType() );
			}
		}
		catch (NoSuchFieldException e) {
			// ignore
		}
		return null;
	}

	@Override
	public <E> E getJavaConstant(String className, String fieldName, Class<E> javaTypeClass) {
		try {
			final var referencedField = getJavaField( className, fieldName );
			if ( referencedField == null ) {
				throw new IllegalArgumentException( "Referenced field '" + fieldName
						+ "' of class '" + className + "' does not exist" );
			}
			if ( !javaTypeClass.isAssignableFrom( canonicalize( referencedField.getType() ) ) ) {
				throw new IllegalArgumentException( "Referenced field '" + fieldName
						+ "' of class '" + className
						+ "' is not assignable to '" + javaTypeClass.getTypeName() + "'" );
			}
			return javaTypeClass.cast( referencedField.get( null) );
		}
		catch (NoSuchFieldException | IllegalAccessException e) {
			throw new RuntimeException( e );
		}
	}

	private Field getJavaField(String className, String fieldName) throws NoSuchFieldException {
		final Class<?> namedClass = classLoaderService.classForName( className );
		return namedClass == null ? null : namedClass.getDeclaredField( fieldName );
	}

View on GitHub (pinned to fad1729dce)

Solutions

  1. Correct the field name in the mapping/lookup so it matches an actual declared field of the class.
  2. Add the missing field to the class if the mapping is correct.

When it happens

Trigger: Thrown during static metamodel or annotation processing when a referenced field does not exist on the given class.

Common situations: See trigger scenarios.


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