Skip to content

Commit

Permalink
HHH-13565 Micro cleanup of Trace level checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanne committed Aug 22, 2019
1 parent 91299ae commit cc39f54
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
Expand Up @@ -814,20 +814,22 @@ public void delete(String entityName, Object object) throws HibernateException {
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(
new DeleteEvent(
entityName,
object,
isCascadeDeleteEnabled,
persistenceContext.isRemovingOrphanBeforeUpates(),
removingOrphanBeforeUpates,
this
),
transientEntities
);
if ( log.isTraceEnabled() && persistenceContext.isRemovingOrphanBeforeUpates() ) {
if ( traceEnabled && removingOrphanBeforeUpates ) {
logRemoveOrphanBeforeUpdates( "after continuing", entityName, object );
}
}
Expand All @@ -836,7 +838,8 @@ public void delete(String entityName, Object object, boolean isCascadeDeleteEnab
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();
Expand All @@ -846,7 +849,7 @@ public void removeOrphanBeforeUpdates(String entityName, Object child) {
}
finally {
persistenceContext.endRemoveOrphanBeforeUpdates();
if ( log.isTraceEnabled() ) {
if ( traceEnabled ) {
logRemoveOrphanBeforeUpdates( "end", entityName, child );
}
}
Expand Down
Expand Up @@ -82,13 +82,20 @@ public List extractResults(

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;
}

Expand All @@ -109,12 +116,14 @@ public List extractResults(
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 );

Expand All @@ -125,7 +134,9 @@ public List extractResults(
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();
Expand Down

0 comments on commit cc39f54

Please sign in to comment.