Skip to content

Commit 80020f0

Browse files
committed
HHH-20125 Fix ComponentType#replace for polymorphic embeddables
1 parent 00a33c4 commit 80020f0

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public ComponentType(Component component, int[] originalPropertyOrder, boolean m
117117
if ( discriminator != null ) {
118118
this.discriminatorColumnSpan = discriminator.getColumnSpan();
119119
this.propertyNames[i] = DISCRIMINATOR_ROLE_NAME;
120-
this.propertyTypes[i] = discriminator.getType();
120+
this.propertyTypes[i] = component.getDiscriminatorType();
121121
this.propertyNullability[i] = false;
122122
this.cascade[i] = CascadeStyles.NONE;
123123
this.joinedFetch[i] = FetchMode.SELECT;
@@ -543,7 +543,7 @@ public Object replace(
543543
copyCache
544544
);
545545

546-
if ( target == null || !isMutable() ) {
546+
if ( target == null || !isMutable() || embeddableTypeDescriptor().isPolymorphic() ) {
547547
return instantiator( original ).instantiate( () -> replacedValues );
548548
}
549549
else {
@@ -577,7 +577,7 @@ public Object replace(
577577
foreignKeyDirection
578578
);
579579

580-
if ( target == null || !isMutable() ) {
580+
if ( target == null || !isMutable() || embeddableTypeDescriptor().isPolymorphic() ) {
581581
return instantiator( original ).instantiate( () -> replacedValues );
582582
}
583583
else {

0 commit comments

Comments
 (0)