HHH-9663 - Fix orphan removal cascade for one-to-one mappings.
This commit is contained in:
parent
0677bb365f
commit
561941c486
|
@ -90,11 +90,13 @@ public final class Cascade {
|
||||||
for ( int i = 0; i < types.length; i++) {
|
for ( int i = 0; i < types.length; i++) {
|
||||||
final CascadeStyle style = cascadeStyles[ i ];
|
final CascadeStyle style = cascadeStyles[ i ];
|
||||||
final String propertyName = propertyNames[ i ];
|
final String propertyName = propertyNames[ i ];
|
||||||
|
final boolean isUninitializedProperty =
|
||||||
|
hasUninitializedLazyProperties &&
|
||||||
|
!persister.getInstrumentationMetadata().isAttributeLoaded( parent, propertyName );
|
||||||
|
|
||||||
Object child = null;
|
if ( style.doCascade( action ) ) {
|
||||||
if ( style.doCascade( action ) || action.deleteOrphans() ) {
|
final Object child;
|
||||||
if ( hasUninitializedLazyProperties &&
|
if ( isUninitializedProperty ) {
|
||||||
!persister.getInstrumentationMetadata().isAttributeLoaded( parent, propertyName ) ) {
|
|
||||||
// parent is a bytecode enhanced entity.
|
// parent is a bytecode enhanced entity.
|
||||||
// cascading to an uninitialized, lazy value.
|
// cascading to an uninitialized, lazy value.
|
||||||
if ( types[ i ].isCollectionType() ) {
|
if ( types[ i ].isCollectionType() ) {
|
||||||
|
@ -121,9 +123,6 @@ public final class Cascade {
|
||||||
else {
|
else {
|
||||||
child = persister.getPropertyValue( parent, i );
|
child = persister.getPropertyValue( parent, i );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( style.doCascade( action ) ) {
|
|
||||||
cascadeProperty(
|
cascadeProperty(
|
||||||
action,
|
action,
|
||||||
cascadePoint,
|
cascadePoint,
|
||||||
|
@ -138,21 +137,24 @@ public final class Cascade {
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if ( action.requiresNoCascadeChecking() ) {
|
else {
|
||||||
|
if ( action.requiresNoCascadeChecking() ) {
|
||||||
action.noCascade(
|
action.noCascade(
|
||||||
eventSource,
|
eventSource,
|
||||||
parent,
|
parent,
|
||||||
persister,
|
persister,
|
||||||
types[ i ],
|
types[i],
|
||||||
i
|
i
|
||||||
);
|
);
|
||||||
if ( action.deleteOrphans() ) {
|
}
|
||||||
|
// If the property is uninitialized, then there cannot be any orphans.
|
||||||
|
if ( action.deleteOrphans() && !isUninitializedProperty ) {
|
||||||
cascadeLogicalOneToOneOrphanRemoval(
|
cascadeLogicalOneToOneOrphanRemoval(
|
||||||
action,
|
action,
|
||||||
eventSource,
|
eventSource,
|
||||||
componentPathStackDepth,
|
componentPathStackDepth,
|
||||||
parent,
|
parent,
|
||||||
child,
|
persister.getPropertyValue( parent, i ),
|
||||||
types[ i ],
|
types[ i ],
|
||||||
style,
|
style,
|
||||||
propertyName,
|
propertyName,
|
||||||
|
|
Loading…
Reference in New Issue