@@ -113,16 +113,16 @@ public <S extends T> Flux<S> saveAll(Iterable<S> entities) {
113113 Streamable <S > source = Streamable .of (entities );
114114
115115 return source .stream ().allMatch (entityInformation ::isNew ) ? //
116- mongoOperations . insert (source . stream (). collect ( Collectors . toList ()), entityInformation . getCollectionName ()) : //
117- Flux .fromIterable (entities ).flatMapSequential (this ::save );
116+ insert (entities ) :
117+ Flux .fromIterable (entities ).concatMap (this ::save );
118118 }
119119
120120 @ Override
121121 public <S extends T > Flux <S > saveAll (Publisher <S > entityStream ) {
122122
123123 Assert .notNull (entityStream , "The given Publisher of entities must not be null" );
124124
125- return Flux .from (entityStream ).flatMapSequential (entity -> entityInformation .isNew (entity ) ? //
125+ return Flux .from (entityStream ).concatMap (entity -> entityInformation .isNew (entity ) ? //
126126 mongoOperations .insert (entity , entityInformation .getCollectionName ()) : //
127127 mongoOperations .save (entity , entityInformation .getCollectionName ()));
128128 }
@@ -296,7 +296,7 @@ public Mono<Void> deleteAll(Publisher<? extends T> entityStream) {
296296 Optional <ReadPreference > readPreference = getReadPreference ();
297297 return Flux .from (entityStream )//
298298 .map (entityInformation ::getRequiredId )//
299- .flatMap (id -> deleteById (id , readPreference ))//
299+ .concatMap (id -> deleteById (id , readPreference ))//
300300 .then ();
301301 }
302302
@@ -337,17 +337,15 @@ public <S extends T> Flux<S> insert(Iterable<S> entities) {
337337 Assert .notNull (entities , "The given Iterable of entities must not be null" );
338338
339339 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 ());
342341 }
343342
344343 @ Override
345344 public <S extends T > Flux <S > insert (Publisher <S > entities ) {
346345
347346 Assert .notNull (entities , "The given Publisher of entities must not be null" );
348347
349- return Flux .from (entities )
350- .flatMapSequential (entity -> mongoOperations .insert (entity , entityInformation .getCollectionName ()));
348+ return Flux .from (entities ).concatMap (this ::insert );
351349 }
352350
353351 // -------------------------------------------------------------------------
0 commit comments