Skip to content

Commit 6dbb8b3

Browse files
committed
HHH-15235 Add test for issue
1 parent a62ca31 commit 6dbb8b3

File tree

2 files changed

+85
-1
lines changed

2 files changed

+85
-1
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
5+
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
6+
*/
7+
package org.hibernate.test.annotations.onetoone;
8+
9+
import java.io.Serializable;
10+
11+
import org.hibernate.testing.TestForIssue;
12+
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
13+
14+
import javax.persistence.CascadeType;
15+
import javax.persistence.Embeddable;
16+
import javax.persistence.EmbeddedId;
17+
import javax.persistence.Entity;
18+
import javax.persistence.JoinColumn;
19+
import javax.persistence.OneToOne;
20+
import javax.persistence.Table;
21+
22+
import org.junit.Test;
23+
24+
@TestForIssue(jiraKey = "HHH-15235")
25+
public class EmbeddedIdTest extends BaseCoreFunctionalTestCase {
26+
27+
@Override
28+
protected Class<?>[] getAnnotatedClasses() {
29+
return new Class[] { Bar.class, Foo.class };
30+
}
31+
32+
@Test
33+
public void testMerge() {
34+
inTransaction(
35+
session -> {
36+
FooId fooId = new FooId();
37+
fooId.id = "foo";
38+
Foo foo = new Foo();
39+
foo.id = fooId;
40+
Bar bar = new Bar();
41+
BarId barId = new BarId();
42+
barId.id = 1l;
43+
bar.id = barId;
44+
foo.bar = bar;
45+
bar.foo = foo;
46+
session.merge( foo );
47+
}
48+
);
49+
}
50+
51+
@Embeddable
52+
public static class BarId implements Serializable {
53+
private Long id;
54+
}
55+
56+
@Embeddable
57+
public static class FooId implements Serializable {
58+
private String id;
59+
}
60+
61+
@Entity(name = "Bar")
62+
@Table(name = "BAR_TABLE")
63+
public static class Bar {
64+
@EmbeddedId
65+
private BarId id;
66+
67+
private String name;
68+
69+
@OneToOne(mappedBy = "bar")
70+
private Foo foo;
71+
}
72+
73+
@Entity(name = "Foo")
74+
@Table(name = "FOO_TABLE")
75+
public static class Foo {
76+
@EmbeddedId
77+
private FooId id;
78+
79+
private String name;
80+
81+
@OneToOne(cascade = CascadeType.ALL)
82+
@JoinColumn(name = "bar_id")
83+
private Bar bar;
84+
}
85+
}

hibernate-core/src/test/java/org/hibernate/test/onetoone/flush/DirtyFlushTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public void testDirtyFlushNotHappened() {
5959
user.profile = profile;
6060

6161
em.persist( profile );
62-
em.flush();
6362
} );
6463

6564
inTransaction( getOrCreateEntityManager(), em -> {

0 commit comments

Comments
 (0)