HHH-13565 Micro cleanup of Trace level checks

This commit is contained in:
Sanne Grinovero 2019-08-20 21:18:38 +01:00
parent 91299aeb7f
commit cc39f54717
2 changed files with 25 additions and 11 deletions

View File

@ -814,7 +814,9 @@ public void delete(String entityName, Object object) throws HibernateException {
public void delete(String entityName, Object object, boolean isCascadeDeleteEnabled, Set transientEntities) public void delete(String entityName, Object object, boolean isCascadeDeleteEnabled, Set transientEntities)
throws HibernateException { throws HibernateException {
checkOpenOrWaitingForAutoClose(); checkOpenOrWaitingForAutoClose();
if ( log.isTraceEnabled() && persistenceContext.isRemovingOrphanBeforeUpates() ) { final boolean removingOrphanBeforeUpates = persistenceContext.isRemovingOrphanBeforeUpates();
final boolean traceEnabled = log.isTraceEnabled();
if ( traceEnabled && removingOrphanBeforeUpates ) {
logRemoveOrphanBeforeUpdates( "before continuing", entityName, object ); logRemoveOrphanBeforeUpdates( "before continuing", entityName, object );
} }
fireDelete( fireDelete(
@ -822,12 +824,12 @@ public void delete(String entityName, Object object, boolean isCascadeDeleteEnab
entityName, entityName,
object, object,
isCascadeDeleteEnabled, isCascadeDeleteEnabled,
persistenceContext.isRemovingOrphanBeforeUpates(), removingOrphanBeforeUpates,
this this
), ),
transientEntities transientEntities
); );
if ( log.isTraceEnabled() && persistenceContext.isRemovingOrphanBeforeUpates() ) { if ( traceEnabled && removingOrphanBeforeUpates ) {
logRemoveOrphanBeforeUpdates( "after continuing", entityName, object ); logRemoveOrphanBeforeUpdates( "after continuing", entityName, object );
} }
} }
@ -836,7 +838,8 @@ public void delete(String entityName, Object object, boolean isCascadeDeleteEnab
public void removeOrphanBeforeUpdates(String entityName, Object child) { public void removeOrphanBeforeUpdates(String entityName, Object child) {
// TODO: The removeOrphan concept is a temporary "hack" for HHH-6484. This should be removed once action/task // TODO: The removeOrphan concept is a temporary "hack" for HHH-6484. This should be removed once action/task
// ordering is improved. // ordering is improved.
if ( log.isTraceEnabled() ) { final boolean traceEnabled = log.isTraceEnabled();
if ( traceEnabled ) {
logRemoveOrphanBeforeUpdates( "begin", entityName, child ); logRemoveOrphanBeforeUpdates( "begin", entityName, child );
} }
persistenceContext.beginRemoveOrphanBeforeUpdates(); persistenceContext.beginRemoveOrphanBeforeUpdates();
@ -846,7 +849,7 @@ public void removeOrphanBeforeUpdates(String entityName, Object child) {
} }
finally { finally {
persistenceContext.endRemoveOrphanBeforeUpdates(); persistenceContext.endRemoveOrphanBeforeUpdates();
if ( log.isTraceEnabled() ) { if ( traceEnabled ) {
logRemoveOrphanBeforeUpdates( "end", entityName, child ); logRemoveOrphanBeforeUpdates( "end", entityName, child );
} }
} }

View File

@ -82,13 +82,20 @@ public List extractResults(
handlePotentiallyEmptyCollectionRootReturns( loadPlan, queryParameters.getCollectionKeys(), resultSet, session ); handlePotentiallyEmptyCollectionRootReturns( loadPlan, queryParameters.getCollectionKeys(), resultSet, session );
final boolean traceEnabled = LOG.isTraceEnabled();
final int maxRows; final int maxRows;
final List loadResults;
final RowSelection selection = queryParameters.getRowSelection(); final RowSelection selection = queryParameters.getRowSelection();
if ( LimitHelper.hasMaxRows( selection ) ) { if ( LimitHelper.hasMaxRows( selection ) ) {
maxRows = selection.getMaxRows(); maxRows = selection.getMaxRows();
LOG.tracef( "Limiting ResultSet processing to just %s rows", maxRows ); if ( traceEnabled ) {
LOG.tracef( "Limiting ResultSet processing to just %s rows", maxRows );
}
int sizeHint = maxRows < 50 ? maxRows : 50;
loadResults = new ArrayList( sizeHint );
} }
else { else {
loadResults = new ArrayList();
maxRows = Integer.MAX_VALUE; maxRows = Integer.MAX_VALUE;
} }
@ -109,12 +116,14 @@ public List extractResults(
hadSubselectFetches hadSubselectFetches
); );
final List loadResults = new ArrayList(); if ( traceEnabled ) {
LOG.trace( "Processing result set" );
LOG.trace( "Processing result set" ); }
int count; int count;
for ( count = 0; count < maxRows && resultSet.next(); count++ ) { for ( count = 0; count < maxRows && resultSet.next(); count++ ) {
LOG.debugf( "Starting ResultSet row #%s", count ); if ( traceEnabled ) {
LOG.tracef( "Starting ResultSet row #%s", count );
}
Object logicalRow = rowReader.readRow( resultSet, context ); Object logicalRow = rowReader.readRow( resultSet, context );
@ -125,7 +134,9 @@ public List extractResults(
context.finishUpRow(); context.finishUpRow();
} }
LOG.tracev( "Done processing result set ({0} rows)", count ); if ( traceEnabled ) {
LOG.tracev( "Done processing result set ({0} rows)", count );
}
rowReader.finishUp( context, afterLoadActionList ); rowReader.finishUp( context, afterLoadActionList );
context.wrapUp(); context.wrapUp();