13
13
import org .hibernate .annotations .FetchMode ;
14
14
import org .hibernate .reactive .testing .DBSelectionExtension ;
15
15
16
- import org .junit .jupiter .api .Disabled ;
17
16
import org .junit .jupiter .api .Test ;
18
17
import org .junit .jupiter .api .extension .RegisterExtension ;
19
18
@@ -80,17 +79,19 @@ public void testMergeDetached(VertxTestContext context) {
80
79
) ) );
81
80
}
82
81
83
- @ Disabled // see https://github.com/hibernate/hibernate-reactive/issues/1504
84
82
@ Test
85
83
public void testMergeReference (VertxTestContext context ) {
86
84
Bar bar = new Bar ( "unique3" );
87
85
test ( context , getSessionFactory ()
88
86
.withTransaction ( session -> session .persist ( bar ) )
89
87
.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
+ } )
91
92
)
92
- .thenCompose ( result -> getSessionFactory ()
93
- .withTransaction ( session -> session .fetch ( result .bar )
93
+ .thenCompose ( merged -> getSessionFactory ()
94
+ .withTransaction ( session -> session .fetch ( merged .bar )
94
95
.thenAccept ( b -> assertEquals ( "unique3" , b .key ) )
95
96
) ) );
96
97
}
@@ -121,13 +122,29 @@ static class Foo {
121
122
Foo () {
122
123
}
123
124
124
- @ GeneratedValue
125
125
@ Id
126
+ @ GeneratedValue
126
127
long id ;
127
128
@ ManyToOne (cascade = CascadeType .PERSIST , fetch = FetchType .LAZY )
128
129
@ Fetch (FetchMode .SELECT )
129
130
@ JoinColumn (name = "bar_key" , referencedColumnName = "nat_key" )
130
131
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
+ }
131
148
}
132
149
133
150
@ Entity (name = "Bar" )
@@ -139,12 +156,20 @@ static class Bar implements Serializable {
139
156
Bar () {
140
157
}
141
158
142
- @ GeneratedValue
143
159
@ Id
160
+ @ GeneratedValue
144
161
long id ;
145
162
@ Column (name = "nat_key" , unique = true )
146
163
String key ;
147
164
165
+ public long getId () {
166
+ return id ;
167
+ }
168
+
169
+ public void setId (long id ) {
170
+ this .id = id ;
171
+ }
172
+
148
173
public String getKey () {
149
174
return key ;
150
175
}
0 commit comments