{"record":{"id":"08ba560b26083303","repo":"hibernate/hibernate-orm","slug":"class-on-which-to-find-field-propertyname","errorCode":null,"errorMessage":"Class<?> on which to find field [\" + propertyName + \"] cannot be null","messagePattern":"Class<\\?> on which to find field \\[\" \\+ propertyName \\+ \"\\] cannot be null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/internal/util/ReflectHelper.java","lineNumber":390,"sourceCode":"\t\t\treturn clazz.getMethod( method.getName(), method.getParameterTypes() );\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tpublic static Method getMethod(Class<?> clazz, String methodName, Class<?>... paramTypes) {\n\t\ttry {\n\t\t\treturn clazz.getMethod( methodName, paramTypes );\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tpublic static Field findField(Class<?> containerClass, String propertyName) {\n\t\tif ( containerClass == null ) {\n\t\t\tthrow new IllegalArgumentException( \"Class<?> on which to find field [\" + propertyName + \"] cannot be null\" );\n\t\t}\n\t\telse if ( containerClass == Object.class ) {\n\t\t\tthrow new IllegalArgumentException( \"Illegal attempt to locate field [\" + propertyName + \"] on Object.class\" );\n\t\t}\n\t\telse {\n\t\t\tfinal Field field = locateField( containerClass, propertyName );\n\t\t\tif ( field == null ) {\n\t\t\t\tthrow new PropertyNotFoundException(\n\t\t\t\t\t\tString.format(\n\t\t\t\t\t\t\t\tLocale.ROOT,\n\t\t\t\t\t\t\t\t\"Could not locate field name [%s] on class [%s]\",\n\t\t\t\t\t\t\t\tpropertyName,\n\t\t\t\t\t\t\t\tcontainerClass.getName()\n\t\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t\tensureAccessibility( field );\n\t\t\treturn field;","sourceCodeStart":372,"sourceCodeEnd":408,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/internal/util/ReflectHelper.java#L372-L408","documentation":"Error \"Class<?> on which to find field [\" + propertyName + \"] cannot be null\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown at hibernate-core/src/main/java/org/hibernate/internal/util/ReflectHelper.java:390 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a non-null Class to the field lookup; null-check the declaring class first."],"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"}