Skip to content

Commit 5c1edfa

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

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
@@ -78,6 +78,7 @@ static Implementation wrap(
7878
TypeDescription targetType = FieldLocator.ForClassHierarchy.Factory.INSTANCE.make( targetEntity )
7979
.locate( bidirectionalAttributeName )
8080
.getField()
81+
.asDefined()
8182
.getType()
8283
.asErasure();
8384

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
@@ -30,6 +30,7 @@
3030
import java.util.Set;
3131

3232
import static org.assertj.core.api.Assertions.assertThat;
33+
import static org.assertj.core.api.Assertions.assertThatNoException;
3334

3435
@DomainModel(
3536
annotatedClasses = {
@@ -101,6 +102,14 @@ public void test(SessionFactoryScope scope) {
101102
} );
102103
}
103104

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

0 commit comments

Comments
 (0)