Hi,
I'm trying to fetch a list of objects where each root object has its own collections. Since there will be hundreds of thousands of instances I'd need to read them iterating over each one by one or with some kind of pagination. So far, I've been unable to do this.
The problem is that ScrollableResults seems to read rows, not objects. Let's say you have a "Parent" object with a collection of three "Child" objects. You will get after the joins three rows. Each call to ScrollableResults.next() retrieves the next row that means that you will have three parents with a child each.
Even using a .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) in the criteria doesn't solve this.
Another way would be to set the first result and the number of results like:
Code:
.setFirstResult(firstRow)
.setMaxResults(numberOfRows)
But this also doesn't work. Again, it's row oriented, not object oriented.
How are you handling this ? Any comment about this would be really welcome.
Regards,
- Juan