hibernate/hibernate-orm · error · IllegalArgumentException
Referenced field '${fieldName}' of class '${className}' is n
Error message
Referenced field '${fieldName}' of class '${className}' is not assignable to '${javaTypeName}' What it means
Error "Referenced field '${fieldName}' of class '${className}' is not assignable to '${javaTypeName}'" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java:395
.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 );
}
@Override
public void addNamedEntityGraph(String graphName, RootGraphImplementor<?> rootGraph) {
final var old = entityGraphMap.put( graphName, rootGraph.makeCopy( false, graphName ) );View on GitHub (pinned to fad1729dce)
Solutions
- Change the referenced field's type to one assignable to the expected Java type, or fix the expected type in the mapping.
When it happens
Trigger: Thrown when a referenced field exists but its type is not assignable to the expected Java type of the attribute.
Common situations: See trigger scenarios.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/527a8374f94a3264.
Report an issue: GitHub.