ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michal Malecki" <misie...@poczta.onet.pl>
Subject Re: What is N+1
Date Wed, 09 Feb 2005 12:39:23 GMT
Not exactly - Abdullah fliped the problem and wanted to selected children,
and parent for each other. Then you don't need group by. When you want
parent and list of children - then of course you are right.
Michal Malecki

>
> >Well, I think you need only simple join in your sql, no extra features of
> >ibatis needed:
> >select * from CHILD, PARENT where parent_id=PARENT.id;
> >am I right?
> >
> Well, that's the right query, but only if you use groupBy.  Assuming
> you're trying to get Parent objects populated with their correct Child
> objects, you query will return something like:
>
> parent_id | child_id
> ----------+---------
> 1         | a
> 1         | b
> 1         | c
> 2         | d
>
> Without groupBy in your resultMap, you'll end up with 3 parent objects,
> each with one child.  What you wanted was 2 parents, one with three
> children.
>
> So you're right, groupBy allows you to do this with one query, but
> before v2.0.9 you'd've needed two separate ones to get the right result.
>
> Kris
>
> -- 
> Kris Jenkins
> Email:  kris@jenkster.com
> Blog:   http://cafe.jenkster.com/
> Wiki:   http://wiki.jenkster.com/
>
>
>



Mime
View raw message