Good point Larry! My domain objects look like this:

Restaurant --> waitersTeam --> John, Tim, Cindy
               --> managersTeam --> Mary, Steven

I have SQL Maps for both the waitersTeam and the managersTeam.

Now, I want to fetch Restaurant objects with a single query based on INNER
JOIN.

The result map for the Restaurant reuses the SQL Maps for waitersTeam and
managersTeam like this:

<result property="waiters" column="RESTAURANT.WAITERS_TEAM_ID"
resultMap="waitersTeam.result" />

The groupBy attribute is set to “id, waitersTeamId, managersTeamId”.

The problem is that I end up with:

Restaurant --> waitersTeam --> John, Tim, Cindy, John, Tim, Cindy
               --> managersTeam --> Mary, Steven, Mary, Steven

Any idea how to fix the bug?




Larry Meadors wrote:
> 
> 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 <[EMAIL PROTECTED]> 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.
>>
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Duplicates-when-trying-to-avoid-N%2B1-selects-tp18404580p18405919.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.

Reply via email to