HHH-9106 : Merging multiple representations of the same entity (improved logging)
This commit is contained in:
parent
7d4ca57c8b
commit
fed3191eb7
|
@ -93,18 +93,14 @@ public class EntityCopyAllowedLoggedObserver extends EntityCopyAllowedObserver {
|
||||||
detachedEntitiesForManaged = managedToMergeEntitiesXref.get( managedEntity );
|
detachedEntitiesForManaged = managedToMergeEntitiesXref.get( managedEntity );
|
||||||
}
|
}
|
||||||
if ( detachedEntitiesForManaged == null ) {
|
if ( detachedEntitiesForManaged == null ) {
|
||||||
// There were no existing representations; instantiate detachedEntitiesForManaged
|
// There were no existing representations for this particular managed entity;
|
||||||
detachedEntitiesForManaged = new IdentitySet();
|
detachedEntitiesForManaged = new IdentitySet();
|
||||||
managedToMergeEntitiesXref.put( managedEntity, detachedEntitiesForManaged );
|
managedToMergeEntitiesXref.put( managedEntity, detachedEntitiesForManaged );
|
||||||
}
|
|
||||||
// Now add the detached representation for the managed entity; only count the
|
|
||||||
// entity copies that have not already been added to detachedEntitiesForManaged.
|
|
||||||
if ( detachedEntitiesForManaged.add( mergeEntity1 ) ) {
|
|
||||||
incrementEntityNameCount( entityName );
|
|
||||||
}
|
|
||||||
if ( detachedEntitiesForManaged.add( mergeEntity2 ) ) {
|
|
||||||
incrementEntityNameCount( entityName );
|
incrementEntityNameCount( entityName );
|
||||||
}
|
}
|
||||||
|
// Now add the detached representation for the managed entity;
|
||||||
|
detachedEntitiesForManaged.add( mergeEntity1 );
|
||||||
|
detachedEntitiesForManaged.add( mergeEntity2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void incrementEntityNameCount(String entityName) {
|
private void incrementEntityNameCount(String entityName) {
|
||||||
|
@ -134,7 +130,6 @@ public class EntityCopyAllowedLoggedObserver extends EntityCopyAllowedObserver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void topLevelMergeComplete(EventSource session) {
|
public void topLevelMergeComplete(EventSource session) {
|
||||||
// Log the summary.
|
// Log the summary.
|
||||||
|
@ -144,7 +139,7 @@ public class EntityCopyAllowedLoggedObserver extends EntityCopyAllowedObserver {
|
||||||
final int count = entry.getValue();
|
final int count = entry.getValue();
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
String.format(
|
String.format(
|
||||||
"%s entity copies merged: %d",
|
"Summary: number of %s entities with multiple representations merged: %d",
|
||||||
entityName,
|
entityName,
|
||||||
count
|
count
|
||||||
)
|
)
|
||||||
|
@ -159,9 +154,9 @@ public class EntityCopyAllowedLoggedObserver extends EntityCopyAllowedObserver {
|
||||||
for ( Map.Entry<Object,Set<Object>> entry : managedToMergeEntitiesXref.entrySet() ) {
|
for ( Map.Entry<Object,Set<Object>> entry : managedToMergeEntitiesXref.entrySet() ) {
|
||||||
Object managedEntity = entry.getKey();
|
Object managedEntity = entry.getKey();
|
||||||
Set mergeEntities = entry.getValue();
|
Set mergeEntities = entry.getValue();
|
||||||
StringBuilder sb = new StringBuilder( "Found ")
|
StringBuilder sb = new StringBuilder( "Details: merged ")
|
||||||
.append( mergeEntities.size() )
|
.append( mergeEntities.size() )
|
||||||
.append( " entity representations of the same entity " )
|
.append( " representations of the same entity " )
|
||||||
.append(
|
.append(
|
||||||
MessageHelper.infoString(
|
MessageHelper.infoString(
|
||||||
session.getEntityName( managedEntity ),
|
session.getEntityName( managedEntity ),
|
||||||
|
|
Loading…
Reference in New Issue