Java ParallelStream with Spring Data JPA

1.3k Views Asked by At

I'm trying to use Java's parallel streams to retrieve records form postgres using Spring Data JPA. If I use the non parallel stream method I get the expected number of results returned. If I use the parallel parallelStream method I get one less returned with the same data. I'm unable to show production code but below is an example of what I'm doing.

  List<JpaEntityObject> duplicateEntityList =
  mapOfNewEntities.entrySet().parallelStream()
          .flatMap(key -> getDuplicateRecordsUsingJpa(key.getKey()).stream())
          .collect(Collectors.toList());
0

There are 0 best solutions below