richwin wrote:
Hi,
I'm wondering how the hibernate paging working.
let's say I have a big result(10000 rows) need to be paged.there are functions like setFirstResult(0), setMaxResults(9) in hibernate,
hibernate will
1. only retrieve 10 rows from database, or
2. retrieve 10000 rows and put to a collection,then filter out first 10 rows from the collection.
if Hibernate use the 2nd way, it's still take time for each page even there is only few rows on each page
please explain.
thank you
Joh
If you take a look at the SQL Hibernate generates you'll see that it uses option 1. Possibility 2 would kill any application that potentially returns more than a few thousand results.
Erik