From: <hib...@li...> - 2006-08-09 21:12:59
|
Author: epbernard Date: 2006-08-09 17:12:56 -0400 (Wed, 09 Aug 2006) New Revision: 10237 Modified: trunk/Hibernate3/src/org/hibernate/engine/Cascade.java trunk/Hibernate3/src/org/hibernate/engine/CascadingAction.java Log: HHH-1992 avoid cascading checking on lazy properties if it does not make sense Modified: trunk/Hibernate3/src/org/hibernate/engine/Cascade.java =================================================================== --- trunk/Hibernate3/src/org/hibernate/engine/Cascade.java 2006-08-09 21:12:00 UTC (rev 10236) +++ trunk/Hibernate3/src/org/hibernate/engine/Cascade.java 2006-08-09 21:12:56 UTC (rev 10237) @@ -241,12 +241,17 @@ CascadeStyle[] cascadeStyles = persister.getPropertyCascadeStyles(); for ( int i=0; i<types.length; i++) { CascadeStyle style = cascadeStyles[i]; - if ( style.doCascade(action) ) { - // associations cannot be field-level lazy="true", so don't - // need to check that the field is fetched (laziness for - // associations is always done by proxying currently) + EntityMode entityMode = eventSource.getEntityMode(); + if ( persister.getPropertyLaziness()[i] + && ! action.performOnLazyProperty() + && persister.hasUninitializedLazyProperties( parent, entityMode ) + //currently there is no way to lazy a property an not the others + ) { + //do nothing to avoid a lazy property initialization + } + else if ( style.doCascade(action) ) { cascadeProperty( - persister.getPropertyValue( parent, i, eventSource.getEntityMode() ), + persister.getPropertyValue( parent, i, entityMode ), types[i], style, anything, @@ -254,13 +259,16 @@ ); } else { - action.noCascade( - eventSource, - persister.getPropertyValue( parent, i, eventSource.getEntityMode() ), - parent, - persister, - i - ); + + if ( action.requiresNoCascadeChecking() ) { + action.noCascade( + eventSource, + persister.getPropertyValue( parent, i, entityMode ), + parent, + persister, + i + ); + } } } Modified: trunk/Hibernate3/src/org/hibernate/engine/CascadingAction.java =================================================================== --- trunk/Hibernate3/src/org/hibernate/engine/CascadingAction.java 2006-08-09 21:12:00 UTC (rev 10236) +++ trunk/Hibernate3/src/org/hibernate/engine/CascadingAction.java 2006-08-09 21:12:56 UTC (rev 10237) @@ -130,6 +130,9 @@ public boolean deleteOrphans() { return false; } + public boolean performOnLazyProperty() { + return false; + } public String toString() { return "ACTION_EVICT"; } @@ -154,6 +157,9 @@ // orphans should be deleted during save/update return true; } + public boolean performOnLazyProperty() { + return false; + } public String toString() { return "ACTION_SAVE_UPDATE"; } @@ -227,6 +233,9 @@ public boolean deleteOrphans() { return false; } + public boolean performOnLazyProperty() { + return false; + } public String toString() { return "ACTION_PERSIST"; } @@ -280,6 +289,9 @@ } } } + public boolean performOnLazyProperty() { + return false; + } private boolean isInManagedState(Object child, EventSource session) { EntityEntry entry = session.getPersistenceContext().getEntry( child ); @@ -350,4 +362,7 @@ return !(collection instanceof PersistentCollection) || ( (PersistentCollection) collection ).wasInitialized(); } + public boolean performOnLazyProperty() { + return true; + } } \ No newline at end of file |