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 final class SessionImpl
public void delete(String entityName, Object object, boolean isCascadeDeleteEnabled, Set transientEntities)
throws HibernateException {
checkOpenOrWaitingForAutoClose();
if ( log.isTraceEnabled() && persistenceContext.isRemovingOrphanBeforeUpates() ) {
final boolean removingOrphanBeforeUpates = persistenceContext.isRemovingOrphanBeforeUpates();
final boolean traceEnabled = log.isTraceEnabled();
if ( traceEnabled && removingOrphanBeforeUpates ) {
logRemoveOrphanBeforeUpdates( "before continuing", entityName, object );
}
fireDelete(
@ -822,12 +824,12 @@ public final class SessionImpl
entityName,
object,
isCascadeDeleteEnabled,
persistenceContext.isRemovingOrphanBeforeUpates(),
removingOrphanBeforeUpates,
this
),
transientEntities
);
if ( log.isTraceEnabled() && persistenceContext.isRemovingOrphanBeforeUpates() ) {
if ( traceEnabled && removingOrphanBeforeUpates ) {
logRemoveOrphanBeforeUpdates( "after continuing", entityName, object );
}
}
@ -836,7 +838,8 @@ public final class SessionImpl
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
// ordering is improved.
if ( log.isTraceEnabled() ) {
final boolean traceEnabled = log.isTraceEnabled();
if ( traceEnabled ) {
logRemoveOrphanBeforeUpdates( "begin", entityName, child );
}
persistenceContext.beginRemoveOrphanBeforeUpdates();
@ -846,7 +849,7 @@ public final class SessionImpl
}
finally {
persistenceContext.endRemoveOrphanBeforeUpdates();
if ( log.isTraceEnabled() ) {
if ( traceEnabled ) {
logRemoveOrphanBeforeUpdates( "end", entityName, child );
}
}

View File

@ -82,13 +82,20 @@ public class ResultSetProcessorImpl implements ResultSetProcessor {
handlePotentiallyEmptyCollectionRootReturns( loadPlan, queryParameters.getCollectionKeys(), resultSet, session );
final boolean traceEnabled = LOG.isTraceEnabled();
final int maxRows;
final List loadResults;
final RowSelection selection = queryParameters.getRowSelection();
if ( LimitHelper.hasMaxRows( selection ) ) {
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 {
loadResults = new ArrayList();
maxRows = Integer.MAX_VALUE;
}
@ -109,12 +116,14 @@ public class ResultSetProcessorImpl implements ResultSetProcessor {
hadSubselectFetches
);
final List loadResults = new ArrayList();
LOG.trace( "Processing result set" );
if ( traceEnabled ) {
LOG.trace( "Processing result set" );
}
int 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 );
@ -125,7 +134,9 @@ public class ResultSetProcessorImpl implements ResultSetProcessor {
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 );
context.wrapUp();