HHH-15651 Logging guard improvements in StatefulPersistenceContext

This commit is contained in:
Sanne Grinovero 2022-11-01 16:42:21 +00:00 committed by Sanne Grinovero
parent bedbd402e6
commit 001de2b203
1 changed files with 16 additions and 9 deletions

View File

@ -1376,6 +1376,9 @@ public class StatefulPersistenceContext implements PersistenceContext {
final EntityPersister persister = metamodel.getEntityDescriptor( entity );
final CollectionPersister cp = metamodel.getCollectionDescriptor( entity + '.' + property );
//Extracted as we're logging within two hot loops
final boolean debugEnabled = LOG.isDebugEnabled();
// try cache lookup first
final Object parent = getParentsByChild( childEntity );
if ( parent != null ) {
@ -1389,12 +1392,14 @@ public class StatefulPersistenceContext implements PersistenceContext {
final Object unMergedChild = mergeMap.get( childEntity );
if ( unMergedInstance != null && unMergedChild != null ) {
index = getIndexInParent( property, unMergedChild, persister, cp, unMergedInstance );
if ( debugEnabled ) {
LOG.debugf(
"A detached object being merged (corresponding to a parent in parentsByChild) has an indexed collection that [%s] the detached child being merged. ",
( index != null ? "contains" : "does not contain" )
);
}
}
}
if ( index != null ) {
return index;
}
@ -1417,12 +1422,14 @@ public class StatefulPersistenceContext implements PersistenceContext {
final Object unMergedChild = mergeMap.get( childEntity );
if ( unMergedInstance != null && unMergedChild!=null ) {
index = getIndexInParent( property, unMergedChild, persister, cp, unMergedInstance );
if ( debugEnabled ) {
LOG.debugf(
"A detached object being merged (corresponding to a managed entity) has an indexed collection that [%s] the detached child being merged. ",
(index != null ? "contains" : "does not contain" )
);
}
}
}
if ( index != null ) {
return index;