0

I have an API (POST) that as a result is returning a list of 90 objects, therefore I want to return a pageable result and I do no how

public ResponseDto<Plans> createlPlans(){
-------
return new ResponseDto(PlanRepository.saveAll(PlanList))}
Maria-Elena
  • 127
  • 1
  • 11

1 Answers1

0

Check out this snippet from SimpleJpaRepository.class

@Transactional
public <S extends T> List<S> saveAll(Iterable<S> entities) {
    Assert.notNull(entities, "Entities must not be null!");
    List<S> result = new ArrayList();
    Iterator var3 = entities.iterator();

    while(var3.hasNext()) {
        S entity = var3.next();
        result.add(this.save(entity));
    }

    return result;
}

The items are being added to the new ArrayList. There are no overloaded methods as well, which is why I think there is no way for you to achieve the behaviour.

You can, however, get the sublist and return. (custom approach)

Suraj Gautam
  • 1,524
  • 12
  • 21