Quote:
How come when I use this I still get all record in the table instead getting 10 record only?
As you will not display the the full table records in only one page you will do some pagination and this is the idea you will fetch the number of records matching the page number you are in.
Imagine you have 500 records and you will display them 10 per page so you will have 50 pages.
so by following the below methodology
List fetchPageData(int startRow, int pageRecordsSize) {
.setMaxResults(pageRecordsSize); // 10
.setFirstResult(startRow); // 1
}
fetchPageData(1, 10);
it will fetch the first 10 records if you make scrolling to third page
make the following call
fetchPageData(20, 10);
hope it helps