99import org .hibernate .cfg .AvailableSettings ;
1010import org .hibernate .cfg .Configuration ;
1111import org .hibernate .reactive .BaseReactiveTest ;
12+ import org .hibernate .reactive .annotations .EnabledFor ;
1213import org .hibernate .reactive .stage .Stage ;
1314import org .hibernate .reactive .testing .SqlStatementTracker ;
1415
2829
2930import static java .util .concurrent .TimeUnit .MINUTES ;
3031import static org .assertj .core .api .Assertions .assertThat ;
32+ import static org .hibernate .reactive .containers .DatabaseConfiguration .DBType .POSTGRESQL ;
3133
3234/**
3335 * Test the stateless session actually execute the operations in batch.
@@ -87,7 +89,7 @@ protected void addServices(StandardServiceRegistryBuilder builder) {
8789 }
8890
8991 private static boolean filter (String s ) {
90- String [] accepted = { "insert " , "update " , "delete " };
92+ String [] accepted = { "merge " , " insert " , "update " , "delete " };
9193 for ( String valid : accepted ) {
9294 if ( s .toLowerCase ().startsWith ( valid ) ) {
9395 return true ;
@@ -96,6 +98,66 @@ private static boolean filter(String s) {
9698 return false ;
9799 }
98100
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+
99161 @ Test
100162 public void testMutinyBatchingInsert (VertxTestContext context ) {
101163 test ( context , getMutinySessionFactory ()
0 commit comments