Skip to content

Commit d2d2186

Browse files
sabbott1877mbellade
authored andcommitted
HHH-19473: Use asDefined type when enhancing BiDirectional Associations to resolve issue with mismatched generated method signatures.
1 parent 0a0e3a4 commit d2d2186

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

hibernate-core/src/main/java/org/hibernate/bytecode/enhance/internal/bytebuddy/BiDirectionalAssociationHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ static Implementation wrap(
8080
TypeDescription targetType = FieldLocator.ForClassHierarchy.Factory.INSTANCE.make( targetEntity )
8181
.locate( bidirectionalAttributeName )
8282
.getField()
83+
.asDefined()
8384
.getType()
8485
.asErasure();
8586

hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/LazyLoadingAndParameterizedInheritanceTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.util.Set;
3333

3434
import static org.assertj.core.api.Assertions.assertThat;
35+
import static org.assertj.core.api.Assertions.assertThatNoException;
3536

3637
@DomainModel(
3738
annotatedClasses = {
@@ -103,6 +104,14 @@ public void test(SessionFactoryScope scope) {
103104
} );
104105
}
105106

107+
@Test
108+
public void testCollectionWrite() {
109+
Three three = new Three();
110+
Two two = new Two();
111+
assertThatNoException().isThrownBy(() -> three.setTwos(Set.of(two)));
112+
assertThat(two.getThree()).isSameAs(three);
113+
}
114+
106115
@Entity(name = "One")
107116
public static class One extends AbsOne<Two> {
108117
}

0 commit comments

Comments
 (0)