views:

218

answers:

2

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

+4  A: 

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

Bozho
+2  A: 

Here's a link to API: ScrollableResults

get() returns the entire current row, get(index) returns object at index position without initializing the rest of them. There are also a bunch of convenience getXXX() methods that cast result to given type.

ChssPly76