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

后端 未结 9 1656
太阳男子
太阳男子 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条回答
  •  佛祖请我去吃肉
    2021-01-30 13:18

    You can still use the Page.map without lambda expressions:

    Page entities = objectEntityRepository.findAll(pageable);
    Page dtoPage = entities.map(new Converter() {
        @Override
        public ObjectDto convert(ObjectEntity entity) {
            ObjectDto dto = new ObjectDto();
            // Conversion logic
    
            return dto;
        }
    });
    

提交回复
热议问题