{"record":{"id":"04d9978bcffa0e41","repo":"hibernate/hibernate-orm","slug":"null-merge-entities-are-not-supported-by","errorCode":null,"errorMessage":"null merge entities are not supported by ","messagePattern":"null merge entities are not supported by ","errorType":"exception","errorClass":"NullPointerException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/event/spi/MergeContext.java","lineNumber":323,"sourceCode":"\t * Returns an unmodifiable Set view of managed entities contained in this MergeContext.\n\t * @return an unmodifiable Set view of managed entities contained in this MergeContext\n\t *\n\t * @see Collections#unmodifiableSet(Set)\n\t */\n\tpublic @Nonnull Collection<Object> values() {\n\t\treturn Collections.unmodifiableSet( managedToMergeEntityXref.keySet() );\n\t}\n\n\t/**\n\t * Returns true if the listener is performing the merge operation on the specified merge entity.\n\t * @param mergeEntity the merge entity; must be non-null\n\t * @return true if the listener is performing the merge operation on the specified merge entity;\n\t * false, if there is no mapping for mergeEntity.\n\t * @throws NullPointerException if mergeEntity is null\n\t */\n\tpublic boolean isOperatedOn(@Nonnull Object mergeEntity) {\n\t\tif ( mergeEntity == null ) {\n\t\t\tthrow new NullPointerException( \"null merge entities are not supported by \" + getClass().getName() );\n\t\t}\n\t\tfinal Boolean isOperatedOn = mergeEntityToOperatedOnFlagMap.get( mergeEntity );\n\t\treturn isOperatedOn != null && isOperatedOn;\n\t}\n\n\t/**\n\t * Set flag to indicate if the listener is performing the merge operation on the specified merge entity.\n\t * @param mergeEntity must be non-null and this MergeContext must contain a cross-reference for mergeEntity\n\t *                       to a managed entity\n\t * @throws NullPointerException if mergeEntity is null\n\t * @throws IllegalStateException if this MergeContext does not contain a a cross-reference for mergeEntity\n\t */\n\tpublic void setOperatedOn(@Nonnull Object mergeEntity, boolean isOperatedOn) {\n\t\tif ( mergeEntity == null ) {\n\t\t\tthrow new NullPointerException( \"null entities are not supported by \" + getClass().getName() );\n\t\t}\n\t\tif ( ! mergeEntityToOperatedOnFlagMap.containsKey( mergeEntity ) ||\n\t\t\t! mergeToManagedEntityXref.containsKey( mergeEntity ) ) {","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/event/spi/MergeContext.java#L305-L341","documentation":"Error \"null merge entities are not supported by \" thrown in hibernate/hibernate-orm.","triggerScenarios":"Thrown when a null key or value is put into the merge-to-managed mapping of a MergeContext.","commonSituations":"Typical situations: merging a graph containing null elements; cascade-merge reaching a null association or collection element.","solutions":["Ensure the merge entity key is non-null before interacting with the merge context."],"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"}