Skip to content

Commit aef88b1

Browse files
dreab8beikov
authored andcommitted
HHH-17420 Add test for issue
1 parent 9201ee7 commit aef88b1

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
package org.hibernate.orm.test.annotations.onetoone;
2+
3+
import java.io.Serializable;
4+
5+
import org.hibernate.testing.junit4.BaseUnitTestCase;
6+
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
7+
import org.hibernate.testing.orm.junit.JiraKey;
8+
import org.hibernate.testing.orm.junit.Jpa;
9+
import org.junit.jupiter.api.Test;
10+
11+
import jakarta.persistence.Column;
12+
import jakarta.persistence.Embeddable;
13+
import jakarta.persistence.EmbeddedId;
14+
import jakarta.persistence.Entity;
15+
import jakarta.persistence.Id;
16+
import jakarta.persistence.JoinColumn;
17+
import jakarta.persistence.OneToOne;
18+
19+
@JiraKey("HHH-17420")
20+
@Jpa(
21+
annotatedClasses = {
22+
JoinColumnTest.LeftEntity.class,
23+
JoinColumnTest.MidEntity.class,
24+
JoinColumnTest.RightEntity.class,
25+
}
26+
)
27+
class JoinColumnTest extends BaseUnitTestCase {
28+
29+
@Test
30+
void testLeftToRight(EntityManagerFactoryScope scope) {
31+
scope.inTransaction(
32+
entityManager -> {
33+
}
34+
);
35+
}
36+
37+
@Entity(name = "LeftEntity")
38+
static class LeftEntity {
39+
40+
@Embeddable
41+
static class Pk implements Serializable {
42+
@Column
43+
String id_one_2;
44+
45+
@Column
46+
String id_two_2;
47+
48+
@Column
49+
String id_three_2;
50+
}
51+
52+
@EmbeddedId
53+
Pk id;
54+
55+
@OneToOne(mappedBy = "aLeftEntity")
56+
MidEntity midEntity;
57+
}
58+
59+
@Entity(name = "MidEntity")
60+
static class MidEntity {
61+
62+
@Id
63+
@Column
64+
String id;
65+
66+
@Column
67+
String id_one;
68+
69+
@Column
70+
String id_two;
71+
72+
@Column
73+
String id_three;
74+
75+
@OneToOne
76+
@JoinColumn(name = "id_one", referencedColumnName = "id_one_2", insertable = false, updatable = false)
77+
@JoinColumn(name = "id_two", referencedColumnName = "id_two_2", insertable = false, updatable = false)
78+
@JoinColumn(name = "id_three", referencedColumnName = "id_three_2", insertable = false, updatable = false)
79+
LeftEntity aLeftEntity;
80+
81+
@OneToOne(mappedBy = "midEntity")
82+
RightEntity rightEntity;
83+
}
84+
85+
@Entity(name = "RightEntity")
86+
static class RightEntity {
87+
88+
@Id
89+
Long id;
90+
91+
@Column
92+
String id_three;
93+
94+
@OneToOne
95+
@JoinColumn(name = "id_one", referencedColumnName = "id_one", insertable = false, updatable = false)
96+
@JoinColumn(name = "id_two", referencedColumnName = "id_two", insertable = false, updatable = false)
97+
MidEntity midEntity;
98+
}
99+
}

0 commit comments

Comments
 (0)