Problems paginating

Hello, I want to exclude results with same idStore in a ExpressionList for paginate.
I just want the list the 2 Stores with thats products for sales, because i have 2 idStore.
image

I get this error

Code:
public CompletableFuture<PagedList> listStore(int id, int page) {
return supplyAsync(() -> {
ExpressionList<(Product)> query = Product.find.query()
.fetch(“productstore”)
.fetch(“productstore.store”)
.orderBy().asc(“productstore.store.name”)
.where()
.eq(" productstore.store.idStore", id);

        int idStore = 0;
        for (Product prod: query.findList()) {
            List<ProductStore> productsStore = prod.productStore;
            for (ProductStore prodStore: productsStore) {
                if (prodStore.store.id == idStore ) {
                    query.ne("productstore.product.id", prod.id);
                }
                idStore = prodStore.store.id;
            }
        }

return query.setFirstRow(page*5).setMaxRows(5).findPagedList();
}, httpExecutionContext.current());