You can really use a thread to simplify the inner loop.
You can replace:
List<Object> ids = entry.getValue(); for (Object id : ids) { Object entity = queryService.query(entityName, queryService.property("id").eq(id)); multiFieldsList.add(entity); }
from:
entry.getValue().map( id -> queryService.query(entityName, queryService.property("id").eq(id)) ).forEach(multiFieldsList::add);
But you donβt really win anything. Your choice...
See @Eran answer for a full flow solution.
source share