HHH-9985 - bytecode enhancer - fix merge use case for composites
This commit is contained in:
parent
f759c152e2
commit
716e954f49
|
@ -415,6 +415,7 @@ public class DefaultMergeEventListener extends AbstractSaveEventListener impleme
|
|||
final Object[] copiedValues = TypeHelper.replace(
|
||||
persister.getPropertyValues( entity ),
|
||||
persister.getPropertyValues( target ),
|
||||
persister.getPropertyNames(),
|
||||
persister.getPropertyTypes(),
|
||||
source,
|
||||
target,
|
||||
|
@ -452,6 +453,7 @@ public class DefaultMergeEventListener extends AbstractSaveEventListener impleme
|
|||
copiedValues = TypeHelper.replace(
|
||||
persister.getPropertyValues( entity ),
|
||||
persister.getPropertyValues( target ),
|
||||
persister.getPropertyNames(),
|
||||
persister.getPropertyTypes(),
|
||||
source,
|
||||
target,
|
||||
|
|
|
@ -524,9 +524,10 @@ public class ComponentType extends AbstractType implements CompositeType, Proced
|
|||
Object[] values = TypeHelper.replace(
|
||||
getPropertyValues( original, entityMode ),
|
||||
getPropertyValues( result, entityMode ),
|
||||
propertyNames,
|
||||
propertyTypes,
|
||||
session,
|
||||
owner,
|
||||
result,
|
||||
copyCache
|
||||
);
|
||||
|
||||
|
@ -556,9 +557,10 @@ public class ComponentType extends AbstractType implements CompositeType, Proced
|
|||
Object[] values = TypeHelper.replace(
|
||||
getPropertyValues( original, entityMode ),
|
||||
getPropertyValues( result, entityMode ),
|
||||
propertyNames,
|
||||
propertyTypes,
|
||||
session,
|
||||
owner,
|
||||
result,
|
||||
copyCache,
|
||||
foreignKeyDirection
|
||||
);
|
||||
|
|
|
@ -10,6 +10,8 @@ import java.io.Serializable;
|
|||
import java.util.Map;
|
||||
|
||||
import org.hibernate.bytecode.instrumentation.spi.LazyPropertyInitializer;
|
||||
import org.hibernate.engine.spi.CompositeOwner;
|
||||
import org.hibernate.engine.spi.CompositeTracker;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.property.access.internal.PropertyAccessStrategyBackRefImpl;
|
||||
import org.hibernate.tuple.NonIdentifierAttribute;
|
||||
|
@ -147,6 +149,7 @@ public class TypeHelper {
|
|||
public static Object[] replace(
|
||||
final Object[] original,
|
||||
final Object[] target,
|
||||
final String[] names,
|
||||
final Type[] types,
|
||||
final SessionImplementor session,
|
||||
final Object owner,
|
||||
|
@ -176,6 +179,11 @@ public class TypeHelper {
|
|||
else {
|
||||
copied[i] = types[i].replace( original[i], target[i], session, owner, copyCache );
|
||||
}
|
||||
|
||||
// for bytecode enhanced entities, set the composite tracking structure
|
||||
if ( copied[i] instanceof CompositeTracker && owner instanceof CompositeOwner ) {
|
||||
( (CompositeTracker) copied[i] ).$$_hibernate_setOwner( names[i], (CompositeOwner) owner );
|
||||
}
|
||||
}
|
||||
return copied;
|
||||
}
|
||||
|
@ -196,6 +204,7 @@ public class TypeHelper {
|
|||
public static Object[] replace(
|
||||
final Object[] original,
|
||||
final Object[] target,
|
||||
final String[] names,
|
||||
final Type[] types,
|
||||
final SessionImplementor session,
|
||||
final Object owner,
|
||||
|
@ -210,6 +219,11 @@ public class TypeHelper {
|
|||
else {
|
||||
copied[i] = types[i].replace( original[i], target[i], session, owner, copyCache, foreignKeyDirection );
|
||||
}
|
||||
|
||||
// for bytecode enhanced entities, set the composite tracking structure
|
||||
if ( copied[i] instanceof CompositeTracker && owner instanceof CompositeOwner ) {
|
||||
( (CompositeTracker) copied[i] ).$$_hibernate_setOwner( names[i], (CompositeOwner) owner );
|
||||
}
|
||||
}
|
||||
return copied;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue