We're trying to iterate over a large number of rows from the database and convert those into objects. Behavior will be as follows:
UPDATE 1:
UPDATE 2
Thanks and hope to hear your insights on this.
It seems you need some sort of pagination. iBatis does that through the standard LIMIT/OFFSET parameters in the query (and RowBounds in iBatis 3 ).
But it seems (if I get it right) that you also are using the GROUP BY feature of iBatis, so that a select returning N records with N1 distint "idx" fields result in the creation of N1 "parent" objects each one having several children objects (with a total of N children objects created). Or something like that.
Unfortunately (and understandably) both things do not mix well.
I dont' see any silver bullet here, one can think of many approaches, each has its shortcomings - hard to evaluate without more information.
If the main objects are "big" (many records) and each one will be processed individually (with a trip to a remote server) you might even want to do an ad-hoc pagination, with a object per page, remembering internally the previosuly read id (something like SELECT ... FROM ... WHERE id = (SELECT MIN(id) FROM .... WHERE id > #lastid#
) )