I've had to execute a query using SQL rather than HQL or Criterions.
The query will typically return in excess of 3000 rows. Typically I'll only been interested in the first X number of rows (X is unknown and is determined when processing the results returned). The problem I have is that when I execute the query ...
Code:
SQLQuery query = session.createSQLQuery();
List<Object[]> results = query.list(); // Fetches everything
for (Object[] row : results) {
// Process the row returned
}
... Hibernate seems to try and retrieve (and populate into objects) all the rows returned by the query even though I'll only be interested in the first X rows. Is there a way you can configure the number of rows populated and retrieved at a time so that the results are retrieved in batches? i.e. retrieve me 50 rows at a time.