diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java index 9cd16998d5..bbd601ff94 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java @@ -6,7 +6,6 @@ */ package org.hibernate.cfg; -import org.hibernate.CustomEntityDirtinessStrategy; import org.hibernate.jpa.LegacySpecHints; import org.hibernate.jpa.SpecHints; @@ -137,24 +136,30 @@ public interface AvailableSettings * @since 5.2 */ String ALLOW_REFRESH_DETACHED_ENTITY = "hibernate.allow_refresh_detached_entity"; + /** - * Setting that specifies how Hibernate will respond when multiple representations of - * the same persistent entity ("entity copy") are detected while merging. + * Specifies how Hibernate should behave when multiple representations of the same + * persistent entity instance, that is, multiple detached objects with the same + * persistent identity, are encountered while cascading a + * {@link org.hibernate.Session#merge(Object) merge()} operation. *

* The possible values are: *

*

- * Alternatively, the application may customize the behavior by providing an + * Alternatively, the application may customize the behavior by providing a custom * implementation of {@link org.hibernate.event.spi.EntityCopyObserver} and setting - * the property {@value #MERGE_ENTITY_COPY_OBSERVER} to the class name. + * the property {@value #MERGE_ENTITY_COPY_OBSERVER} to the class name. This, in + * principle, allows the application program to specify rules for reconciling + * conflicts. *

* When this property is set to {@code allow} or {@code log}, Hibernate will merge * each entity copy detected while cascading the merge operation. In the process of @@ -164,6 +169,8 @@ public interface AvailableSettings * merging an entity copy will be overwritten when another entity copy is merged. * * @since 4.3 + * + * @see org.hibernate.event.spi.EntityCopyObserver */ @SuppressWarnings("JavaDoc") String MERGE_ENTITY_COPY_OBSERVER = "hibernate.event.merge.entity_copy_observer"; @@ -191,7 +198,7 @@ public interface AvailableSettings * Setting to identify a {@link org.hibernate.CustomEntityDirtinessStrategy} to use. * May specify either a class name or an instance. * - * @see org.hibernate.boot.SessionFactoryBuilder#applyCustomEntityDirtinessStrategy(CustomEntityDirtinessStrategy) + * @see org.hibernate.boot.SessionFactoryBuilder#applyCustomEntityDirtinessStrategy */ String CUSTOM_ENTITY_DIRTINESS_STRATEGY = "hibernate.entity_dirtiness_strategy"; diff --git a/hibernate-core/src/main/java/org/hibernate/event/spi/MergeContext.java b/hibernate-core/src/main/java/org/hibernate/event/spi/MergeContext.java index e739f2b5a9..c9a83e3e45 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/spi/MergeContext.java +++ b/hibernate-core/src/main/java/org/hibernate/event/spi/MergeContext.java @@ -234,12 +234,7 @@ public class MergeContext implements Map { // this is a new mapping for mergeEntity in mergeToManagedEntityXref if ( oldMergeEntity != null ) { // oldMergeEntity was a different merge entity with the same corresponding managed entity; - entityCopyObserver.entityCopyDetected( - managedEntity, - mergeEntity, - oldMergeEntity, - session - ); + entityCopyObserver.entityCopyDetected( managedEntity, mergeEntity, oldMergeEntity, session ); } if ( oldOperatedOn != null ) { throw new IllegalStateException(