From fb15ee548ca1c8fb80f77497271931404f54c19e Mon Sep 17 00:00:00 2001 From: Andrej Golovnin Date: Thu, 27 Nov 2014 20:43:44 +0100 Subject: [PATCH] HHH-9328 Avoids creation of Cascade objects at all by converting all methods of the Cascade class into static methods. --- .../hibernate/engine/internal/Cascade.java | 137 ++++++++++++------ .../AbstractFlushingEventListener.java | 2 +- .../internal/AbstractSaveEventListener.java | 10 +- .../internal/DefaultDeleteEventListener.java | 10 +- .../internal/DefaultEvictEventListener.java | 2 +- .../internal/DefaultLockEventListener.java | 5 +- .../internal/DefaultMergeEventListener.java | 5 +- .../internal/DefaultRefreshEventListener.java | 5 +- .../DefaultReplicateEventListener.java | 5 +- .../DefaultSaveOrUpdateEventListener.java | 2 +- 10 files changed, 130 insertions(+), 53 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java b/hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java index 31432ba2ba..7180b6b0e6 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java @@ -58,22 +58,8 @@ import org.hibernate.type.Type; public final class Cascade { private static final CoreMessageLogger LOG = CoreLogging.messageLogger( Cascade.class ); - private int componentPathStackDepth = 0; - private final CascadingAction action; - private final EventSource eventSource; - private CascadePoint cascadePoint; - - /** - * Constructs a Cascade - * - * @param action The action we are cascading - * @param cascadePoint The point in the action at which we are trying to cascade currently - * @param eventSource The session - */ - public Cascade(final CascadingAction action, final CascadePoint cascadePoint, final EventSource eventSource) { - this.cascadePoint = cascadePoint; - this.eventSource = eventSource; - this.action = action; + private Cascade() { + // NOP } /** @@ -81,9 +67,13 @@ public final class Cascade { * * @param persister The parent's entity persister * @param parent The parent reference. + * @throws HibernateException */ - public void cascade(final EntityPersister persister, final Object parent) { - cascade( persister, parent, null ); + public static void cascade( + final CascadingAction action, final CascadePoint cascadePoint, + final EventSource eventSource, final EntityPersister persister, final Object parent) + throws HibernateException { + cascade( action, cascadePoint, eventSource, persister, parent, null ); } /** @@ -95,9 +85,12 @@ public final class Cascade { * @param anything Anything ;) Typically some form of cascade-local cache * which is specific to each CascadingAction type */ - public void cascade(final EntityPersister persister, final Object parent, final Object anything) { - if ( persister.hasCascades() || action.requiresNoCascadeChecking() ) { - // performance opt + public static void cascade( + final CascadingAction action, final CascadePoint cascadePoint, + final EventSource eventSource, final EntityPersister persister, final Object parent, final Object anything) + throws HibernateException { + + if ( persister.hasCascades() || action.requiresNoCascadeChecking() ) { // performance opt final boolean traceEnabled = LOG.isTraceEnabled(); if ( traceEnabled ) { LOG.tracev( "Processing cascade {0} for: {1}", action, persister.getEntityName() ); @@ -106,6 +99,7 @@ public final class Cascade { final Type[] types = persister.getPropertyTypes(); final CascadeStyle[] cascadeStyles = persister.getPropertyCascadeStyles(); final boolean hasUninitializedLazyProperties = persister.hasUninitializedLazyProperties( parent ); + final int componentPathStackDepth = 0; for ( int i=0; i