Pergunta

I have two resources defined using a PagingAndSortingRepository:

  • galleries/{id}
  • images/{id}

Paging in general for both resources is available by the used repository type.

The gallery itself contains a list of images

@Entity
@Table(name = "Gallery")
public class Gallery extends AbstractEntity {

    private String name;

    @OneToMany(fetch = FetchType.EAGER)
    private List<Image> images;
    ...
}

I can now access the images of a gallery via

  • galleries/1/images

Is it possible to enable paging also for these sub-lists? or what is the REST style for handling those large lists.

thank you in advance, Guido

Foi útil?

Solução

If you make a findByGalleryId query on the images repository, it should return you the results paged. However, I don't understand why the sub-list you're querying isn't paged. Are you sure it has enough records for paging?

Outras dicas

Related to my question here: Spring Data Rest Pageable Child Collection

So far I've been unable to get the collections inside of an object to page the way you describe. I ended up basically doing as Andres suggested.

You can implement a finder on images to return a page and then use @RestResource(exported=false) to hide the link from the gallery side.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top