From b75613cff15deac351542e4195e26888fb63855d Mon Sep 17 00:00:00 2001 From: Gavin King Date: Sun, 30 Jan 2022 13:03:23 +0100 Subject: [PATCH] edit the (excellent) javadoc of MergeContext --- .../event/internal/MergeContext.java | 79 +++++++++---------- .../event/spi/EntityCopyObserver.java | 2 + 2 files changed, 40 insertions(+), 41 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/MergeContext.java b/hibernate-core/src/main/java/org/hibernate/event/internal/MergeContext.java index a67b592c0b..4564d651a5 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/MergeContext.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/MergeContext.java @@ -17,57 +17,54 @@ import org.hibernate.event.spi.EventSource; import org.hibernate.pretty.MessageHelper; /** - * MergeContext is a Map implementation that is intended to be used by a merge - * event listener to keep track of each entity being merged and their corresponding - * managed result. Entities to be merged may to be added to the MergeContext before - * the merge operation has cascaded to that entity. - *

- * "Merge entity" and "mergeEntity" method parameter refer to an entity that is - * (or will be) merged via {@link EventSource#merge(Object mergeEntity)}. - *

- * "Managed entity" and "managedEntity" method parameter refer to the managed entity - * that is the result of merging an entity. - *

- * A merge entity can be transient, detached, or managed. If it is managed, then it - * must be the same as its associated entity result. + * {@code MergeContext} is a specialized {@link Map} implementation used by a + * {@linkplain org.hibernate.event.spi.MergeEventListener merge event listener} + * to keep track of each entity being merged and its corresponding managed result. + * An entity to be merged may to be added to the {@code MergeContext} before the + * merge operation cascades to the entity. + *

+ * A merge entity can be transient, detached, or managed. If it is managed, then + * it is identical to its resulting managed entity. *

* If {@link #put(Object mergeEntity, Object managedEntity)} is called, and this - * MergeContext already contains an entry with a different entity as the key, but - * with the same (managedEntity) value, this means that multiple entity - * representations for the same persistent entity are being merged. If this happens, - * {@link EntityCopyObserver#entityCopyDetected( + * {@code MergeContext} already contains an entry with a different entity as the + * key, but with the same (managed entity) value, this means that multiple entity + * representations for the same persistent entity are being merged. In this + * situation, {@link EntityCopyObserver#entityCopyDetected( * Object managedEntity, Object mergeEntity1, Object mergeEntity2, EventSource)} - * will be called. It is up to that method to determine the property course of - * action for this situation. + * is called to determine an appropriate resolution. *

* There are several restrictions. *

- * The following method is intended to be used by a merge event listener (and other - * classes) in the same package to add a merge entity and its corresponding - * managed entity to a MergeContext and indicate if the merge operation is - * being performed on the merge entity yet. + * The following method is intended to be used by an implementation of + * {@link org.hibernate.event.spi.MergeEventListener} to add a merge entity and its + * corresponding managed entity to a {@code MergeContext} and indicate if the merge + * operation is being performed on the merge entity yet. *

* {@link MergeContext#put(Object mergeEntity, Object managedEntity, boolean isOperatedOn)} *

- * The following method is intended to be used by a merge event listener (and other - * classes) in the same package to indicate whether the merge operation is being - * performed on a merge entity already in the {@link MergeContext}: + * The following method is intended to be used by a {@code MergeEventListener} to + * indicate whether the merge operation is being performed on a merge entity already + * in the {@code MergeContext}: *

* {@link MergeContext#setOperatedOn(Object mergeEntity, boolean isOperatedOn)} * diff --git a/hibernate-core/src/main/java/org/hibernate/event/spi/EntityCopyObserver.java b/hibernate-core/src/main/java/org/hibernate/event/spi/EntityCopyObserver.java index 6afc7d4075..151d3192e0 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/spi/EntityCopyObserver.java +++ b/hibernate-core/src/main/java/org/hibernate/event/spi/EntityCopyObserver.java @@ -9,6 +9,8 @@ package org.hibernate.event.spi; /** * An observer for detection of multiple entity representations for a persistent entity being merged. * + * @see org.hibernate.event.internal.MergeContext + * * @author Gail Badner */ public interface EntityCopyObserver {