Skip to content

Commit

Permalink
HHH-15359 The entity returned by a merge doesn't contain @manytomany
Browse files Browse the repository at this point in the history
…relation when the collection resides in @embeddable
  • Loading branch information
dreab8 committed Aug 25, 2022
1 parent 2a0a618 commit fd3ab8b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions hibernate-core/src/main/java/org/hibernate/type/TypeHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package org.hibernate.type;

import org.hibernate.EntityMode;
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.util.collections.ArrayHelper;
Expand Down Expand Up @@ -245,6 +246,19 @@ else if ( types[i].isComponentType() ) {
Object[] origComponentValues = original[i] == null ? new Object[subtypes.length] : componentType.getPropertyValues( original[i], session );
Object[] targetComponentValues = target[i] == null ? new Object[subtypes.length] : componentType.getPropertyValues( target[i], session );
replaceAssociations( origComponentValues, targetComponentValues, subtypes, session, null, copyCache, foreignKeyDirection );
final Object[] objects = replaceAssociations(
origComponentValues,
targetComponentValues,
subtypes,
session,
null,
copyCache,
foreignKeyDirection
);
if ( target[i] != null && objects != null ) {
// Need to account for entity mode on the CompositeType interface, that seems not been used by any implementation
componentType.setPropertyValues( target[i], objects, EntityMode.POJO );
}
copied[i] = target[i];
}
else if ( !types[i].isAssociationType() ) {
Expand Down

0 comments on commit fd3ab8b

Please sign in to comment.