{"record":{"id":"9b3ae3b9e89a72cb","repo":"hibernate/hibernate-orm","slug":"entity-may-not-be-null-9b3ae3","errorCode":null,"errorMessage":"Entity may not be null","messagePattern":"Entity may not be null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java","lineNumber":1625,"sourceCode":"\t\t\t\t\t\t\tuee.getMessage()\n\t\t\t\t\t\t\t\t+ \" ('\" + entityClass.getSimpleName() + \"' \" + problem + \")\",\n\t\t\t\t\t\t\te\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// not for internal use:\n\n\t@Override\n\t@Nullable\n\tpublic Object getIdentifier(@Nonnull Object object) {\n\t\tcheckOpen();\n\t\tcheckTransactionSyncStatus();\n\t\t//noinspection ConstantValue\n\t\tif ( object == null ) {\n\t\t\tthrow new IllegalArgumentException( \"Entity may not be null\" );\n\t\t}\n\t\tfinal var lazyInitializer = extractLazyInitializer( object );\n\t\tif ( lazyInitializer != null ) {\n\t\t\tcheckOwnsProxy( lazyInitializer );\n\t\t\treturn lazyInitializer.getInternalIdentifier();\n\t\t}\n\t\telse {\n\t\t\treturn getEntityEntry( object ).getId();\n\t\t}\n\t}\n\n\t/**\n\t * Get the id value for an object that is actually associated with the session.\n\t * This is a bit stricter than\n\t * {@link org.hibernate.engine.internal.ForeignKeys#getEntityIdentifierIfNotUnsaved}.\n\t */\n\t@Override\n\tpublic Object getContextEntityIdentifier(@Nonnull Object object) {","sourceCodeStart":1607,"sourceCodeEnd":1643,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java#L1607-L1643","documentation":"Error \"Entity may not be null\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown at hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java:1625 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a non-null entity instance to the Session operation; null-check the object before calling persist/merge/remove/etc.","If the entity may legitimately be absent, guard the call with an Optional or explicit if (entity != null)."],"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"}