File tree 2 files changed +31
-0
lines changed
main/java/org/springframework/data/r2dbc/repository/support
test/java/org/springframework/data/r2dbc/repository/support
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 15
15
*/
16
16
package org .springframework .data .r2dbc .repository .support ;
17
17
18
+ import org .springframework .data .util .StreamUtils ;
19
+ import org .springframework .data .util .Streamable ;
20
+ import org .springframework .util .CollectionUtils ;
18
21
import reactor .core .publisher .Flux ;
19
22
import reactor .core .publisher .Mono ;
20
23
35
38
import org .springframework .transaction .annotation .Transactional ;
36
39
import org .springframework .util .Assert ;
37
40
41
+ import java .util .List ;
42
+
38
43
/**
39
44
* Simple {@link ReactiveSortingRepository} implementation using R2DBC through {@link DatabaseClient}.
40
45
*
@@ -304,6 +309,16 @@ public Mono<Void> deleteAll(Iterable<? extends T> iterable) {
304
309
return deleteAll (Flux .fromIterable (iterable ));
305
310
}
306
311
312
+ @ Override
313
+ public Mono <Void > deleteAllById (Iterable <? extends ID > ids ) {
314
+
315
+ Assert .notNull (ids , "The iterable of Id's must not be null!" );
316
+
317
+ List <? extends ID > idsList = Streamable .of (ids ).toList ();
318
+ String idProperty = getIdProperty ().getName ();
319
+ return this .entityOperations .delete (Query .query (Criteria .where (idProperty ).in (idsList )), this .entity .getJavaType ()).then ();
320
+ }
321
+
307
322
/* (non-Javadoc)
308
323
* @see org.springframework.data.repository.reactive.ReactiveCrudRepository#deleteAll(org.reactivestreams.Publisher)
309
324
*/
Original file line number Diff line number Diff line change 16
16
package org .springframework .data .r2dbc .repository .support ;
17
17
18
18
import static org .assertj .core .api .Assertions .*;
19
+ import static org .testcontainers .shaded .com .google .common .primitives .Ints .*;
19
20
20
21
import lombok .AllArgsConstructor ;
21
22
import lombok .Data ;
57
58
* @author Mark Paluch
58
59
* @author Bogdan Ilchyshyn
59
60
* @author Stephen Cohen
61
+ * @author Jens Schauder
60
62
*/
61
63
public abstract class AbstractSimpleR2dbcRepositoryIntegrationTests extends R2dbcIntegrationTestSupport {
62
64
@@ -465,6 +467,20 @@ void shouldDeleteAllUsingPublisher() {
465
467
assertThat (count ).isEqualTo (0 );
466
468
}
467
469
470
+ @ Test // gh-498
471
+ void shouldDeleteAllById () {
472
+
473
+ jdbc .execute ("INSERT INTO legoset (name, manual) VALUES('SCHAUFELRADBAGGER', 12)" );
474
+ Integer id = jdbc .queryForObject ("SELECT id FROM legoset" , Integer .class );
475
+
476
+ repository .deleteAllById (asList (id )) //
477
+ .as (StepVerifier ::create ) //
478
+ .verifyComplete ();
479
+
480
+ Integer count = jdbc .queryForObject ("SELECT COUNT(*) FROM legoset" , Integer .class );
481
+ assertThat (count ).isEqualTo (0 );
482
+ }
483
+
468
484
@ Data
469
485
@ Table ("legoset" )
470
486
@ AllArgsConstructor
You can’t perform that action at this time.
0 commit comments