How to map Page to Page in spring-data-rest

后端 未结 9 1642
太阳男子
太阳男子 2021-01-30 12:37

When I hit the database with PagingAndSortingRepository.findAll(Pageable) I get Page. However, I want to expose DTO\'s to the clien

9条回答
  •  梦毁少年i
    2021-01-30 13:12

    And in java8:

    Page entities = 
     objectEntityRepository.findAll(pageable)
     .map(ObjectDto::fromEntity);
    

    Where fromEntity is a static method on ObjectDto that contains the conversion logic.

提交回复
热议问题