From: Martin D. <mar...@ge...> - 2007-06-29 07:12:47
|
Andrea Aime a écrit : >> This is an amazing example of being lazy - the Set is returned - and >> each call to iterator() will produce a result set ... > > (...snip...) > > how about a compromise: you gather all of the ids, keep a reference > to the DataSource, and then issue a query every 100 object, loading > the results in memory and closing the resultset and connection right > away? Just a note on the intend: one assumption behind AuthorityCodes was that it would have two typical usages: * Get the AuthorityCode set and iterate over all the ID. This usage can be well handled by the above proposal. * Just want to check if an ID exists, with: factory.getAuthorityCodes().contains(theID); In the later case, gathering all ID is a more extensive work than needed. My attempt behind AuthorityCodes was to map "Set.contains(...)" to a simple "SELECT name FROM ... WHERE ID=?" in order to take advantage of database index without loading any of the 3000+ ID. This is a PreparedStatement that current AuthorityCodes keep as long as it is alive, it order to allow efficient execution of Set.containsAll(...) for example. Martin |