I've had a brief chat with Emmanuel about this, he suggested to look into the database's support for scrollable results;
I've found this:
http://lists.mysql.com/java/8523It appears MySQL doesn't support them, the driver implements it loading it all in memory.
the post is quite old, maybe it has been fixed, but for sure not in the versions you are using;
It's also possible that latest DB versions do support it but the driver has not been updated.
I'm going to try it myself moving all actors (DB server, JDBC driver, hibernate) to "nightly build" or latest I can find as I am curious and I might hit the same problem soon, but I'll definitely suggest you to switch away from scrollable for now;
use pagination with the list() API and setFirstResult and setMaxResults.
Or try the latest indexing API of Hibernate Search, it will give you more benefits like using several threads to speed up indexing: you will need that having millions of records; I've said it's not production ready as I can't say that for a snapshot version, but I do use it in production myself. Just be aware that the method names are not final.