{"record":{"id":"b9c3d0a122aeacba","repo":"hibernate/hibernate-orm","slug":"entity-class-may-not-be-null","errorCode":null,"errorMessage":"Entity class may not be null","messagePattern":"Entity class may not be null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java","lineNumber":2211,"sourceCode":"\n\t@Override\n\t@Nullable\n\tpublic <T> T find(\n\t\t\t@Nonnull Class<T> entityClass,\n\t\t\t@Nonnull Object primaryKey,\n\t\t\t@Nonnull LockModeType lockModeType,\n\t\t\t@Nullable Map<String, Object> properties) {\n\t\t//noinspection ConstantValue\n\t\tif ( lockModeType == null ) {\n\t\t\tthrow new IllegalArgumentException(\"Given LockModeType was null\");\n\t\t}\n\t\treturn doFind( entityClass, primaryKey, LockMode.fromJpaLockMode( lockModeType ), properties );\n\t}\n\n\tprivate <T> T doFind(Class<T> entityClass, Object primaryKey, LockMode lockMode, Map<String, Object> properties) {\n\t\tcheckOpen();\n\t\tif ( entityClass == null ) {\n\t\t\tthrow new IllegalArgumentException( \"Entity class may not be null\" );\n\t\t}\n\t\tfinal var options = determineFindOptions( lockMode, properties );\n\t\tfinal var entityDescriptor = requireEntityPersisterForLoad( entityClass );\n\t\treturn byKeyWithGraph( entityClass, entityDescriptor, properties, options )\n\t\t\t\t.performFind( primaryKey );\n\t}\n\n\tprivate <T> FindByKeyOperation<T> byKeyWithGraph(\n\t\t\tClass<T> entityClass,\n\t\t\tEntityPersister entityDescriptor,\n\t\t\tMap<String, Object> properties,\n\t\t\tFindOption[] options) {\n\t\tfinal var fetchHint = fetchGraphFromHints( properties );\n\t\tfinal var loadHint = loadGraphFromHints( properties );\n\t\tfinal GraphSemantic graphSemantic;\n\t\tfinal RootGraphImplementor<?> graph;\n\t\tif ( fetchHint != null ) {\n\t\t\tif ( loadHint != null ) {","sourceCodeStart":2193,"sourceCodeEnd":2229,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java#L2193-L2229","documentation":"Error \"Entity class may not be null\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown at hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java:2211 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Supply the entity class explicitly (e.g. session.find(MyEntity.class, id)) rather than null.","Verify the class object is not null before the call."],"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"}