|
21 | 21 | import reactor.core.publisher.Mono;
|
22 | 22 |
|
23 | 23 | import java.io.Serializable;
|
24 |
| -import java.util.List; |
| 24 | +import java.util.Collection; |
25 | 25 | import java.util.stream.Collectors;
|
26 | 26 |
|
27 | 27 | import org.reactivestreams.Publisher;
|
| 28 | + |
28 | 29 | import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
29 | 30 | import org.springframework.dao.OptimisticLockingFailureException;
|
30 | 31 | import org.springframework.data.domain.Example;
|
@@ -174,7 +175,7 @@ public Flux<T> findAllById(Iterable<ID> ids) {
|
174 | 175 | Assert.notNull(ids, "The given Iterable of Id's must not be null!");
|
175 | 176 |
|
176 | 177 | return findAll(new Query(new Criteria(entityInformation.getIdAttribute())
|
177 |
| - .in(Streamable.of(ids).stream().collect(StreamUtils.toUnmodifiableList())))); |
| 178 | + .in(toCollection(ids)))); |
178 | 179 | }
|
179 | 180 |
|
180 | 181 | /*
|
@@ -275,9 +276,9 @@ public <S extends T> Flux<S> insert(Iterable<S> entities) {
|
275 | 276 |
|
276 | 277 | Assert.notNull(entities, "The given Iterable of entities must not be null!");
|
277 | 278 |
|
278 |
| - List<S> source = Streamable.of(entities).stream().collect(StreamUtils.toUnmodifiableList()); |
| 279 | + Collection<S> source = toCollection(entities); |
279 | 280 |
|
280 |
| - return source.isEmpty() ? Flux.empty() : Flux.from(mongoOperations.insertAll(source)); |
| 281 | + return source.isEmpty() ? Flux.empty() : mongoOperations.insertAll(source); |
281 | 282 | }
|
282 | 283 |
|
283 | 284 | /*
|
@@ -437,8 +438,12 @@ private Criteria getIdCriteria(Object id) {
|
437 | 438 | return where(entityInformation.getIdAttribute()).is(id);
|
438 | 439 | }
|
439 | 440 |
|
440 |
| - private Flux<T> findAll(Query query) { |
| 441 | + private static <E> Collection<E> toCollection(Iterable<E> ids) { |
| 442 | + return ids instanceof Collection ? (Collection<E>) ids |
| 443 | + : StreamUtils.createStreamFromIterator(ids.iterator()).collect(Collectors.toList()); |
| 444 | + } |
441 | 445 |
|
| 446 | + private Flux<T> findAll(Query query) { |
442 | 447 | return mongoOperations.find(query, entityInformation.getJavaType(), entityInformation.getCollectionName());
|
443 | 448 | }
|
444 | 449 | }
|
0 commit comments