paging fix for Mongo (and maybe other databases)

Using Query.setFirstResult(int) and Query.setMaxResults(int) results in retrieving more and more rows (first+max) from the DB. After some pages (e.g. hav 70.000 records, and page by 1000) we will quickly consume all available memory (firstResult = 35.000, maxResults = 1000)
This patch should fix this.