Hi Andrew,

I've given this some more thought...

2013/3/27 Andrew Myers <[email protected]>:
> [...]
> To achieve someting similar I was able to do:
>
>             Map<String, List<CountryRecord>> ctry =
> result.intoGroups(COUNTRY.CODE, CountryRecord.class);
>             Map<String, List<CityRecord>> cities =
> result.intoGroups(COUNTRY.CODE, CityRecord.class);
>             for (Map.Entry<String, List<CountryRecord>> entry :
> ctry.entrySet()) {
>                 CountryRecord cr = entry.getValue().get(0);
>                 // print country stuff
>
>                 List<CityRecord> thisCountriesCities =
> cities.get(cr.getCode());
>                 for (CityRecord c : thisCountriesCities) {
>                    // print city stuff
>                 }

The problem that is most apparent here is the fact that at some point,
while constructing the query, you've had all the information about the
table types that you were selecting from. In fact, you have created a
product of <R1> = COUNTRY and <R2> = CITY. While using the jOOQ API,
this information is lost, and all you're left with is a generic Record
type with an unknown set of Field<?>

It would be quite nice, if jOOQ 3.0's row value expression typesafety
could be leveraged to produce something like "nested records". In your
case, each result record could have the type: Record2<CountryRecord,
CityRecord>. Nesting records like this could then help grouping them
by country, producing a Map<CountryRecord, List<CityRecord>> rather
than more generic types. Also, the resulting Record2 records would
really hold references to CountryRecord and CityRecord instances,
while at the same time being compatible with the current, "flat" API

I have registered #2360 for this idea:
https://github.com/jOOQ/jOOQ/issues/2360

Cheers
Lukas

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to