9
9
import org .hibernate .cfg .AvailableSettings ;
10
10
import org .hibernate .cfg .Configuration ;
11
11
import org .hibernate .reactive .BaseReactiveTest ;
12
+ import org .hibernate .reactive .annotations .EnabledFor ;
12
13
import org .hibernate .reactive .stage .Stage ;
13
14
import org .hibernate .reactive .testing .SqlStatementTracker ;
14
15
28
29
29
30
import static java .util .concurrent .TimeUnit .MINUTES ;
30
31
import static org .assertj .core .api .Assertions .assertThat ;
32
+ import static org .hibernate .reactive .containers .DatabaseConfiguration .DBType .POSTGRESQL ;
31
33
32
34
/**
33
35
* Test the stateless session actually execute the operations in batch.
@@ -87,7 +89,7 @@ protected void addServices(StandardServiceRegistryBuilder builder) {
87
89
}
88
90
89
91
private static boolean filter (String s ) {
90
- String [] accepted = { "insert " , "update " , "delete " };
92
+ String [] accepted = { "merge " , " insert " , "update " , "delete " };
91
93
for ( String valid : accepted ) {
92
94
if ( s .toLowerCase ().startsWith ( valid ) ) {
93
95
return true ;
@@ -96,6 +98,66 @@ private static boolean filter(String s) {
96
98
return false ;
97
99
}
98
100
101
+ @ Test
102
+ @ EnabledFor (POSTGRESQL )
103
+ public void testMutinyMergeUpsertAll (VertxTestContext context ) {
104
+ test ( context , getMutinySessionFactory ()
105
+ .withStatelessTransaction ( s -> s .upsertAll ( PIGS ) )
106
+ .invoke ( () -> assertSqlLogTracker ( "merge into pig as t using (.*)" ) )
107
+ .chain ( () -> Uni .createFrom ().completionStage ( assertExpectedResult ( PIGS ) ) )
108
+ );
109
+ }
110
+
111
+ @ Test
112
+ @ EnabledFor (POSTGRESQL )
113
+ public void testMutinyMergeUpsertAllWithBatchSize (VertxTestContext context ) {
114
+ test ( context , getMutinySessionFactory ()
115
+ .withStatelessTransaction ( s -> s .upsertAll ( 10 , PIGS ) )
116
+ .invoke ( () -> assertSqlLogTracker ( "merge into pig as t using (.*)" ) )
117
+ .chain ( () -> Uni .createFrom ().completionStage ( assertExpectedResult ( PIGS ) ) )
118
+ );
119
+ }
120
+
121
+ @ Test
122
+ @ EnabledFor (POSTGRESQL )
123
+ public void testMutinyMergeUpsertMultiple (VertxTestContext context ) {
124
+ test ( context , getMutinySessionFactory ()
125
+ .withStatelessTransaction ( s -> s .upsertMultiple ( List .of ( PIGS ) ) )
126
+ .invoke ( () -> assertSqlLogTracker ( "merge into pig as t using (.*)" ) )
127
+ .chain ( () -> Uni .createFrom ().completionStage ( assertExpectedResult ( PIGS ) ) )
128
+ );
129
+ }
130
+
131
+ @ Test
132
+ @ EnabledFor (POSTGRESQL )
133
+ public void testStageMergeUpsertAll (VertxTestContext context ) {
134
+ test ( context , getSessionFactory ()
135
+ .withStatelessTransaction ( s -> s .upsertAll ( PIGS ) )
136
+ .thenRun ( () -> assertSqlLogTracker ( "merge into pig as t using (.*)" ) )
137
+ .thenCompose ( v -> assertExpectedResult ( PIGS ) )
138
+ );
139
+ }
140
+
141
+ @ Test
142
+ @ EnabledFor (POSTGRESQL )
143
+ public void testStageMergeUpsertAllWithBatchSize (VertxTestContext context ) {
144
+ test ( context , getSessionFactory ()
145
+ .withStatelessTransaction ( s -> s .upsertAll ( 10 , PIGS ) )
146
+ .thenRun (() -> assertSqlLogTracker ( "merge into pig as t using (.*)" ) )
147
+ .thenCompose ( v -> assertExpectedResult ( PIGS ) )
148
+ );
149
+ }
150
+
151
+ @ Test
152
+ @ EnabledFor (POSTGRESQL )
153
+ public void testStageMergeUpsertMultiple (VertxTestContext context ) {
154
+ test ( context , getSessionFactory ()
155
+ .withStatelessTransaction ( s -> s .upsertMultiple ( List .of ( PIGS ) ) )
156
+ .thenRun ( () -> assertSqlLogTracker ( "merge into pig as t using (.*)" ) )
157
+ .thenCompose ( v -> assertExpectedResult ( PIGS ) )
158
+ );
159
+ }
160
+
99
161
@ Test
100
162
public void testMutinyBatchingInsert (VertxTestContext context ) {
101
163
test ( context , getMutinySessionFactory ()
0 commit comments