Hello!
I have a problem with implementation of lazy-loading for Grid. The following code represent DataProvider:
private DataProvider<ReservationDTO, Void> buildDataProvider() {
return DataProvider.fromCallbacks(
query -> {
final List<SortDTO.OrderDTO> orders = query.getSortOrders().stream()
.map(queryOrder -> SortDTO.OrderDTO.builder()
.property(queryOrder.getSorted())
.direction(queryOrder.getDirection() == SortDirection.DESCENDING ? DirectionEnum.ASC : DirectionEnum.DESC)
.build()
)
.collect(Collectors.toList());
if (orders.isEmpty()) {
orders.add(SortDTO.OrderDTO.builder()
.property("createdAt")
.direction(DirectionEnum.ASC)
.build());
}
final FindReservationsRequestDTO request = FindReservationsRequestDTO.builder()
.criteria(buildSearchCriteria())
.sort(SortDTO.builder()
.orders(orders)
.build())
.build();
return reservationsResource.getAllReservations(request, query.getOffset(), query.getLimit()).getContent().stream();
},
query -> reservationsResource.getReservationCount(FindReservationsRequestDTO.builder()
.criteria(buildSearchCriteria())
.build())
);
}
If i understand it right, “offset” and “limit” values of query have to be defined automatically by Vaadin. But when i debug peace of code above i can see that offset = 0, limit = 2147483647. It means that all data from database is loaded by first and only one query. So, lazy-loading in this case doesn’t make any sense.
Please help to understand what i did wrong!