{"record":{"id":"df306b12a20d0209","repo":"hibernate/hibernate-orm","slug":"referenced-field-fieldname-of-class-classn","errorCode":null,"errorMessage":"Referenced field '${fieldName}' of class '${className}' does not exist","messagePattern":"Referenced field '(.+?)' of class '(.+?)' does not exist","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java","lineNumber":391,"sourceCode":"\t\ttry {\n\t\t\tfinal var referencedField = getJavaField( className, fieldName );\n\t\t\tif ( referencedField != null ) {\n\t\t\t\treturn getTypeConfiguration().getJavaTypeRegistry()\n\t\t\t\t\t\t.resolveDescriptor( referencedField.getType() );\n\t\t\t}\n\t\t}\n\t\tcatch (NoSuchFieldException e) {\n\t\t\t// ignore\n\t\t}\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic <E> E getJavaConstant(String className, String fieldName, Class<E> javaTypeClass) {\n\t\ttry {\n\t\t\tfinal var referencedField = getJavaField( className, fieldName );\n\t\t\tif ( referencedField == null ) {\n\t\t\t\tthrow new IllegalArgumentException( \"Referenced field '\" + fieldName\n\t\t\t\t\t\t+ \"' of class '\" + className + \"' does not exist\" );\n\t\t\t}\n\t\t\tif ( !javaTypeClass.isAssignableFrom( canonicalize( referencedField.getType() ) ) ) {\n\t\t\t\tthrow new IllegalArgumentException( \"Referenced field '\" + fieldName\n\t\t\t\t\t\t+ \"' of class '\" + className\n\t\t\t\t\t\t+ \"' is not assignable to '\" + javaTypeClass.getTypeName() + \"'\" );\n\t\t\t}\n\t\t\treturn javaTypeClass.cast( referencedField.get( null) );\n\t\t}\n\t\tcatch (NoSuchFieldException | IllegalAccessException e) {\n\t\t\tthrow new RuntimeException( e );\n\t\t}\n\t}\n\n\tprivate Field getJavaField(String className, String fieldName) throws NoSuchFieldException {\n\t\tfinal Class<?> namedClass = classLoaderService.classForName( className );\n\t\treturn namedClass == null ? null : namedClass.getDeclaredField( fieldName );\n\t}","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java#L373-L409","documentation":"Error \"Referenced field '${fieldName}' of class '${className}' does not exist\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown during static metamodel or annotation processing when a referenced field does not exist on the given class.","commonSituations":"See trigger scenarios.","solutions":["Correct the field name in the mapping/lookup so it matches an actual declared field of the class.","Add the missing field to the class if the mapping is correct."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}