{"record":{"id":"52a93828acdccc13","repo":"hibernate/hibernate-orm","slug":"entity-may-not-be-null-52a938","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/event/spi/PersistEvent.java","lineNumber":30,"sourceCode":" *\n * @author Gavin King\n *\n * @see org.hibernate.Session#persist\n */\npublic class PersistEvent extends AbstractSessionEvent {\n\n\tprivate Object object;\n\tprivate String entityName;\n\n\tpublic PersistEvent(@Nullable String entityName, @Nonnull Object original, @Nonnull EventSource source) {\n\t\tthis(original, source);\n\t\tthis.entityName = entityName;\n\t}\n\n\tpublic PersistEvent(@Nonnull Object object, @Nonnull EventSource source) {\n\t\tsuper(source);\n\t\tif ( object == null ) {\n\t\t\tthrow new IllegalArgumentException( \"Entity may not be null\" );\n\t\t}\n\t\tthis.object = object;\n\t}\n\n\t@Nonnull\n\tpublic Object getObject() {\n\t\treturn object;\n\t}\n\n\tpublic void setObject(@Nonnull Object object) {\n\t\tthis.object = object;\n\t}\n\n\t@Nullable\n\tpublic String getEntityName() {\n\t\treturn entityName;\n\t}\n","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/event/spi/PersistEvent.java#L12-L48","documentation":"Error \"Entity may not be null\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown when a caller passes a null Entity to the API guarded in PersistEvent.java:30.","commonSituations":"Typical situations: calling the method with an uninitialized variable; a lookup that returned null being passed straight through; missing null-checks in application code before invoking Hibernate.","solutions":["Check the entity argument for null before calling persist()."],"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"}