Skip to content

Commit 6bb2e70

Browse files
committed
[#1504] align merge tests with new ORM merge tests
1 parent 52b5fd0 commit 6bb2e70

File tree

2 files changed

+37
-14
lines changed

2 files changed

+37
-14
lines changed

hibernate-reactive-core/src/test/java/org/hibernate/reactive/EagerUniqueKeyTest.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.hibernate.annotations.Fetch;
1313
import org.hibernate.annotations.FetchMode;
1414

15-
import org.junit.jupiter.api.Disabled;
1615
import org.junit.jupiter.api.Test;
1716

1817
import jakarta.persistence.CascadeType;
@@ -73,18 +72,17 @@ public void testMergeDetached(VertxTestContext context) {
7372
) ) );
7473
}
7574

76-
@Disabled // see https://github.com/hibernate/hibernate-reactive/issues/1504
7775
@Test
7876
public void testMergeReference(VertxTestContext context) {
7977
Bar bar = new Bar( "unique3" );
8078
test( context, getSessionFactory()
8179
.withTransaction( session -> session.persist( bar ) )
8280
.thenCompose( i -> getSessionFactory()
83-
.withTransaction( session -> session
84-
.merge( new Foo( session.getReference( Bar.class, bar.getId() ) ) ) ) )
85-
.thenCompose( result -> getSessionFactory().withTransaction( session -> session.fetch( result.getBar() )
86-
.thenAccept( b -> assertEquals( "unique3", b.getKey() ) )
87-
) )
81+
.withTransaction( session -> {
82+
Bar reference = session.getReference( Bar.class, bar.getId() );
83+
return session.merge( new Foo( reference ) );
84+
} ) )
85+
.thenAccept( merged -> assertEquals( merged.getBar().getKey(), bar.getKey() ) )
8886
);
8987
}
9088

hibernate-reactive-core/src/test/java/org/hibernate/reactive/LazyUniqueKeyTest.java

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.hibernate.annotations.FetchMode;
1414
import org.hibernate.reactive.testing.DBSelectionExtension;
1515

16-
import org.junit.jupiter.api.Disabled;
1716
import org.junit.jupiter.api.Test;
1817
import org.junit.jupiter.api.extension.RegisterExtension;
1918

@@ -80,17 +79,19 @@ public void testMergeDetached(VertxTestContext context) {
8079
) ) );
8180
}
8281

83-
@Disabled // see https://github.com/hibernate/hibernate-reactive/issues/1504
8482
@Test
8583
public void testMergeReference(VertxTestContext context) {
8684
Bar bar = new Bar( "unique3" );
8785
test( context, getSessionFactory()
8886
.withTransaction( session -> session.persist( bar ) )
8987
.thenCompose( i -> getSessionFactory()
90-
.withTransaction( session-> session.merge( new Foo( session.getReference( Bar.class, bar.id ) ) ) )
88+
.withTransaction( session-> {
89+
Bar reference = session.getReference( Bar.class, bar.id );
90+
return session.merge( new Foo( reference ) );
91+
} )
9192
)
92-
.thenCompose( result -> getSessionFactory()
93-
.withTransaction( session-> session.fetch( result.bar )
93+
.thenCompose( merged -> getSessionFactory()
94+
.withTransaction( session-> session.fetch( merged.bar )
9495
.thenAccept( b -> assertEquals( "unique3", b.key ) )
9596
) ) );
9697
}
@@ -121,13 +122,29 @@ static class Foo {
121122
Foo() {
122123
}
123124

124-
@GeneratedValue
125125
@Id
126+
@GeneratedValue
126127
long id;
127128
@ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
128129
@Fetch(FetchMode.SELECT)
129130
@JoinColumn(name = "bar_key", referencedColumnName = "nat_key")
130131
Bar bar;
132+
133+
public long getId() {
134+
return id;
135+
}
136+
137+
public void setId(long id) {
138+
this.id = id;
139+
}
140+
141+
public Bar getBar() {
142+
return bar;
143+
}
144+
145+
public void setBar(Bar bar) {
146+
this.bar = bar;
147+
}
131148
}
132149

133150
@Entity(name = "Bar")
@@ -139,12 +156,20 @@ static class Bar implements Serializable {
139156
Bar() {
140157
}
141158

142-
@GeneratedValue
143159
@Id
160+
@GeneratedValue
144161
long id;
145162
@Column(name = "nat_key", unique = true)
146163
String key;
147164

165+
public long getId() {
166+
return id;
167+
}
168+
169+
public void setId(long id) {
170+
this.id = id;
171+
}
172+
148173
public String getKey() {
149174
return key;
150175
}

0 commit comments

Comments
 (0)