You could use the ScrollableResults from hibernate
Something like:
ScrollableResults results = session.createCriteria(Project.class)
.add(Restrictions.eq("projectType", Constants.REINDEX.PROJECT_TYPE))
.setFetchSize(10)
.scroll(ScrollMode.FORWARD_ONLY);
while (results.next()) {
project = (Project) results.get(0);
If you are scrolling through a huge ammount of entities you should probably also clear your session from while to while, else you could run out of memory.
More information is to be found in the documentation 10.4.1.6. Scrollable iteration and as they wrote it, you should use pagination if you don't want your connection to stay open.