Grid Callback Data Provider wrong query parameter values


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()
                    .direction(queryOrder.getDirection() == SortDirection.DESCENDING ? DirectionEnum.ASC : DirectionEnum.DESC)

            if (orders.isEmpty()) {

            final FindReservationsRequestDTO request = FindReservationsRequestDTO.builder()

            return reservationsResource.getAllReservations(request, query.getOffset(), query.getLimit()).getContent().stream();
        query -> reservationsResource.getReservationCount(FindReservationsRequestDTO.builder()

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!

I’m having a slightly similar issue, and I would like to know how Vaadin calculates the offset and limit too.


The offset and limit in the query that goes to the “size” method does indeed have
offset = 0, limit = Integer.MAX_VALUE
. The one going to the actual row fetching should contain initially from 0 to 40, unless you want a different initial row count (see:
). If you do get the “full length” query in your data provider initially, then somewhere something is broken and needs to be fixed.



please find the code below

public List getUserList(int offset,int limit){
//your code
return criteria.list();