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