ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Meadors" <larry.mead...@gmail.com>
Subject Re: Duplicates when trying to avoid N+1 selects
Date Fri, 11 Jul 2008 14:19:18 GMT
FWIW, I got as far as "COMPLEX", "A_GROUP", and "B_GROUP" before I
stopped reading. ;-)

I'm not saying no one else will read or answer you, just that I think
if you can make this a more concrete example, instead of a tuple
calculus exercise, then you might get more (and better) responses.

Larry


On Fri, Jul 11, 2008 at 8:02 AM, mailjoe <mailjoe2008@yahoo.com> wrote:
>
> Hi,
>
> We have a ComplexObject made of one instance of aGroup and one instance of
> bGroup.
> The aGroup is made of a collection of A instances.
> The bGroup is made of a colleciton of B instances.
>
> We have one SQL Map for aGroup, and another one for bGroup.
>
> If aGroup contains m A's and bGroup contains n B's, the query given below
> returns m*n items in the aGroup and bGroup properties:
>
>    <resultMap class="ComplexObject" id="result" groupBy="id, aGroupId,
> bGroupId">
>        <result property="id" column="COMPLEX.OBJECT_ID" />
>        <result property="aGroup" column="COMPLEX.A_GROUP_ID"
> resultMap="aGroup.result" />
>        <result property="bGroup" column="COMPLEX.B_GROUP_ID"
> resultMap="bGroup.result" />
>    </resultMap>
>
>    <select id="getById" resultMap="result">
>        SELECT * FROM COMPLEX
>        INNER JOIN A_GROUP ON A_GROUP_ID = A_GROUP.ID
>        INNER JOIN A ON A.GROUP_ID = A_GROUP_ID
>        INNER JOIN B_GROUP ON B_GROUP_ID = B_GROUP.ID
>        INNER JOIN B ON B.GROUP_ID = B_GROUP_ID
>        WHERE COMPLEX.ID = #value#
>    </select>
>
> Any idea how to fix this bug?
>
> Thanks!
> --
> View this message in context: http://www.nabble.com/Duplicates-when-trying-to-avoid-N%2B1-selects-tp18404580p18404580.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>

Mime
View raw message