1

I have a java web application where I use Hibernate and MySQL. On a page I have a search form where on submit i create a HQL Query to fetch the results.

I used .setFirstResult() and .setMaxResults() for paging. This works fine, but not when my resultset contains alot of records... I thought .setMaxResults() would use limit in the actual SQL query, but it appears it doesn't. So it loads the whole result in memory, and only then uses the value I set in .setMaxResults(), which results in memory problems.

Is this how it works, or am I just doing something wrong?

If so this is just not usable for me.

ps: With Criteria API it does work, but there I had some other limitations on creating the criteria. Thats why I tried to use HQL instead, but I'm now facing this problem.

So am I right in my observations? Is there another solution?

Nathan Q
  • 1,892
  • 17
  • 40
  • 2
    Could this be your problem: http://stackoverflow.com/questions/6348143/hibernate-hql-pagination? – Femi May 04 '12 at 10:11

0 Answers0