Skip to content

Commit 19081ba

Browse files
dreab8beikov
authored andcommitted
HHH-17621 UnsupportedOperationException when merging an entity with a @Any mapping
1 parent 2ec2cf2 commit 19081ba

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

hibernate-core/src/main/java/org/hibernate/type/TypeHelper.java

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -191,27 +191,26 @@ public static Object[] replaceAssociations(
191191
}
192192
else {
193193
final Type type = types[i];
194-
if ( type.isComponentType() ) {
195-
final CompositeType compositeType = (CompositeType) type;
196-
if ( target[i] != null ) {
197-
// need to extract the component values and check for subtype replacements...
198-
final Object[] objects = replaceCompositeAssociations(
199-
session,
200-
copyCache,
201-
foreignKeyDirection,
202-
target[i],
203-
currentOriginal,
204-
compositeType
205-
);
206-
target[i] = compositeType.replacePropertyValues( target[i], objects, session );
207-
}
208-
copied[i] = target[i];
209-
}
210-
else if ( !type.isAssociationType() ) {
211-
copied[i] = target[i];
194+
if ( type.isAssociationType() ) {
195+
copied[i] = types[i].replace( currentOriginal, target[i], session, owner, copyCache, foreignKeyDirection );
212196
}
213197
else {
214-
copied[i] = types[i].replace( currentOriginal, target[i], session, owner, copyCache, foreignKeyDirection );
198+
if ( type.isComponentType() ) {
199+
final CompositeType compositeType = (CompositeType) type;
200+
if ( target[i] != null ) {
201+
// need to extract the component values and check for subtype replacements...
202+
final Object[] objects = replaceCompositeAssociations(
203+
session,
204+
copyCache,
205+
foreignKeyDirection,
206+
target[i],
207+
currentOriginal,
208+
compositeType
209+
);
210+
target[i] = compositeType.replacePropertyValues( target[i], objects, session );
211+
}
212+
}
213+
copied[i] = target[i];
215214
}
216215
}
217216
}

0 commit comments

Comments
 (0)