Skip to content

Commit d60d394

Browse files
committed
HHH-19076 Add second composite key entity to the failing test
1 parent 89ffdba commit d60d394

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/identifier/composite/CompositeInheritanceFailTest.java

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
CompositeInheritanceFailTest.TupAbstractEntity.class,
2828
CompositeInheritanceFailTest.DummyEntity.class,
2929
CompositeInheritanceFailTest.TestEntity.class, // Here the class is called TestEntity
30+
CompositeInheritanceFailTest.Test2Entity.class,
3031
}
3132
)
3233
@ServiceRegistry(
@@ -53,6 +54,18 @@ void hhh19076FailingTest(SessionFactoryScope scope) {
5354
} );
5455
}
5556

57+
@Test
58+
void hhh19076FailingTest2(SessionFactoryScope scope) {
59+
scope.inTransaction( em -> {
60+
Test2Entity e1 = new Test2Entity("foo", "xxxxxx");
61+
em.persist(e1);
62+
63+
CompositeId2Class key = e1.getCompositeId();
64+
Test2Entity e2 = em.find(Test2Entity.class, key);
65+
assertNotNull(e2);
66+
} );
67+
}
68+
5669
@MappedSuperclass
5770
public static abstract class TupAbstractEntity {
5871
@Id
@@ -103,6 +116,32 @@ public CompositeIdClass getCompositeId() {
103116

104117
}
105118

119+
@Entity
120+
@IdClass(CompositeId2Class.class)
121+
public static class Test2Entity extends TupAbstractEntity {
122+
123+
@Id
124+
private String otherId;
125+
126+
protected Test2Entity() {
127+
// for JPA
128+
}
129+
130+
public Test2Entity(String oid, String otherId) {
131+
super(oid);
132+
this.otherId = otherId;
133+
}
134+
135+
public String myId() {
136+
return otherId;
137+
}
138+
139+
public CompositeId2Class getCompositeId() {
140+
return new CompositeId2Class(getOid(), otherId);
141+
}
142+
143+
}
144+
106145
public static class CompositeIdClass {
107146

108147
private String oid;
@@ -126,4 +165,27 @@ public String myId() {
126165

127166
}
128167

168+
public static class CompositeId2Class {
169+
170+
private String oid;
171+
private String otherId;
172+
173+
public CompositeId2Class(String oid, String otherId) {
174+
this.oid = oid;
175+
this.otherId = otherId;
176+
}
177+
178+
public CompositeId2Class() {
179+
}
180+
181+
public String oid() {
182+
return oid;
183+
}
184+
185+
public String otherId() {
186+
return otherId;
187+
}
188+
189+
}
190+
129191
}

0 commit comments

Comments
 (0)