@@ -113,16 +113,16 @@ public <S extends T> Flux<S> saveAll(Iterable<S> entities) {
113
113
Streamable <S > source = Streamable .of (entities );
114
114
115
115
return source .stream ().allMatch (entityInformation ::isNew ) ? //
116
- mongoOperations . insert (source . stream (). collect ( Collectors . toList ()), entityInformation . getCollectionName ()) : //
117
- Flux .fromIterable (entities ).flatMap (this ::save );
116
+ insert (entities ) :
117
+ Flux .fromIterable (entities ).concatMap (this ::save );
118
118
}
119
119
120
120
@ Override
121
121
public <S extends T > Flux <S > saveAll (Publisher <S > entityStream ) {
122
122
123
123
Assert .notNull (entityStream , "The given Publisher of entities must not be null" );
124
124
125
- return Flux .from (entityStream ).flatMapSequential (entity -> entityInformation .isNew (entity ) ? //
125
+ return Flux .from (entityStream ).concatMap (entity -> entityInformation .isNew (entity ) ? //
126
126
mongoOperations .insert (entity , entityInformation .getCollectionName ()) : //
127
127
mongoOperations .save (entity , entityInformation .getCollectionName ()));
128
128
}
@@ -296,7 +296,7 @@ public Mono<Void> deleteAll(Publisher<? extends T> entityStream) {
296
296
Optional <ReadPreference > readPreference = getReadPreference ();
297
297
return Flux .from (entityStream )//
298
298
.map (entityInformation ::getRequiredId )//
299
- .flatMap (id -> deleteById (id , readPreference ))//
299
+ .concatMap (id -> deleteById (id , readPreference ))//
300
300
.then ();
301
301
}
302
302
@@ -337,17 +337,15 @@ public <S extends T> Flux<S> insert(Iterable<S> entities) {
337
337
Assert .notNull (entities , "The given Iterable of entities must not be null" );
338
338
339
339
Collection <S > source = toCollection (entities );
340
-
341
- return source .isEmpty () ? Flux .empty () : mongoOperations .insertAll (source );
340
+ return source .isEmpty () ? Flux .empty () : mongoOperations .insert (source , entityInformation .getCollectionName ());
342
341
}
343
342
344
343
@ Override
345
344
public <S extends T > Flux <S > insert (Publisher <S > entities ) {
346
345
347
346
Assert .notNull (entities , "The given Publisher of entities must not be null" );
348
347
349
- return Flux .from (entities )
350
- .flatMapSequential (entity -> mongoOperations .insert (entity , entityInformation .getCollectionName ()));
348
+ return Flux .from (entities ).concatMap (this ::insert );
351
349
}
352
350
353
351
// -------------------------------------------------------------------------
0 commit comments