Hibernate: how do I retrieve my entities from a ScrollableResults?

Issue

I do a query that returns a list of entities. How can I retrieve the entities from a ScrollableResults:

 Session s  = ....;
 Query q = s.createQuery("....") # returns 100000s rows
 ScrollableResults sr = q.scroll();
 sr.scroll(45999); # just a number
 Employee employee = ???

How do I get an employee in the last line of code

Solution

try the get(0) method, or get()[0]

Answered By – Bozho

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published