{"record":{"id":"a7b99a0bbf7ceee7","repo":"hibernate/hibernate-orm","slug":"identifier-may-not-be-null","errorCode":null,"errorMessage":"Identifier may not be null","messagePattern":"Identifier may not be null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/event/spi/LoadEvent.java","lineNumber":85,"sourceCode":"\t\t\t@Nullable Object instanceToLoad,\n\t\t\t@Nonnull LockOptions lockOptions,\n\t\t\tboolean isAssociationFetch,\n\t\t\t@Nonnull EventSource source,\n\t\t\t@Nullable Boolean readOnly) {\n\t\tsuper( source );\n\t\tthis.entityId = entityId;\n\t\tthis.entityClassName = entityClassName;\n\t\tthis.instanceToLoad = instanceToLoad;\n\t\tthis.lockOptions = lockOptions;\n\t\tthis.isAssociationFetch = isAssociationFetch;\n\t\tthis.readOnly = readOnly;\n\t\tvalidate();\n\t}\n\n\t@Internal\n\tpublic void validate() {\n\t\tif ( entityId == null ) {\n\t\t\tthrow new IllegalArgumentException( \"Identifier may not be null\" );\n\t\t}\n\n\t\tfinal var lockMode = lockOptions.getLockMode();\n\t\tif ( lockMode == LockMode.WRITE ) {\n\t\t\tthrow new IllegalArgumentException( \"Invalid lock mode: \" + LockMode.WRITE );\n\t\t}\n\t\telse if ( lockMode == null ) {\n\t\t\tlockOptions.setLockMode( LockMode.NONE );\n\t\t}\n\t}\n\n\t@Nonnull\n\tpublic Object getEntityId() {\n\t\treturn entityId;\n\t}\n\n\t@Internal\n\tpublic void setEntityId(@Nonnull Object entityId) {","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/event/spi/LoadEvent.java#L67-L103","documentation":"Error \"Identifier may not be null\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown when a caller passes a null Identifier to the API guarded in LoadEvent.java:85.","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":["Ensure the identifier passed to load()/get() is non-null before the call.","Validate the id value earlier in the call chain where it is produced."],"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"}