You may need to use groupBy and a second resultMap, even though you're only using primitives. This will aggregate the external ids beneath the unique types. Map the whole thing to a hashmap. Initially this will get you a List of HashMaps, with types and lists of external ids as you've said. Then, by calling queryForMap you can get a unique map of types with the value of externalIds...
That may make no sense at all, but try to work your way through it to see what you come up with.
Here's a link describing groupBy etc.
http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+get+around+the+N+Plus+1+selects+problem
Clinton
On 8/14/06, Daniel Pitts
<[EMAIL PROTECTED]> wrote:
I have a table that looks something like this:
external_maps
Parent externalId type
1 1 1
1 2 1
1 3 1
1 8 2
1 9 2
1 16 6
I want to do a query like "SELECT externaId, type FROM external_maps
where Parent=%parent%"
I want to get a result that is a Map<Integer, Integer[]> (or
Map<Integer, List<Integer>>) where the key is type and the Integer[] (or
List<Integer)) is the list of externalId values.
Will queryForMap do this? If not, is there another (easy) way to get
this result?
Thanks,
Daniel.
