Hi friends,
I tried below code.
In this, it is not honoring the firstResult() method for query.iterate().
But it is fetching data only based on maximum record property of query object.
Code:
Query query2 = session.createQuery("from Account as c where c.id = '2000'");
query2.setCacheable(true);
query2.setMaxResults(10);
query2.setFirstResult(2);
Iterator<Account> customerIterator2 = query2.iterate();
while(customerIterator2.hasNext())
{
Account account = customerIterator2.next();
System.out.println("Customer Id =" + account.getId() + "Customer Name =" + account.getName());
}
I am expecting that the query will return rowNum > 2 and rowNum < 10, so the total number of rows should be returned is 8.
but actually it is returning 10 rows.
I want only 8 rows not 10 rows, how this functionality i can achieve using hibernate.?