You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Baskar Viswanathan <bv...@wsgc.com> on 2007/04/06 03:28:52 UTC

Group By for one Parent and many Child types.

I m new to Ibatis.

I m having trouble with building a map with Ibatis using group by.

If the relation is like 
GrandParent
	Parent
		   Child 

It works fine..Since I group by GrandParent and Parent.


If the relation is like..
Parent
	Child list1(a1, a2)
	Child list2(b1,b2)
	Child list3(c1,c2,c3)

If I group by Parent and all child lists, only one child list is grouped and the rest is not.
So it creates a cartisian product.

Then the AUTO mapping doesn't work. I might have to manually do the logic to create the maps.

Is there a way in  to make this work?

For example , Use case Customer 

1 Customer has
	2 emails
	3 Addresses
	2 Telephones


thanks for your help..
nathan

Re: Group By for one Parent and many Child types.

Posted by Jeff Butler <je...@gmail.com>.
iBATIS does not support this now - it is a known issue.

You can use groupBy to populate one of the lists, and nested selects to
populate the others.

Jeff Butler


On 4/5/07, Baskar Viswanathan <bv...@wsgc.com> wrote:
>
>  I m new to Ibatis.
>
> I m having trouble with building a map with Ibatis using group by.
>
> If the relation is like
> *GrandParent*
> *        Parent*
> *                   Child *
>
> It works fine..Since I group by GrandParent and Parent.
>
> If the relation is like..
> *Parent*
> *        Child list1(a1, a2)*
> *        Child list2(b1,b2)*
> *        Child list3(c1,c2,c3)*
>
> If I group by Parent and all child lists, only one child list is grouped
> and the rest is not.
> So it creates a cartisian product.**
>
> Then the AUTO mapping doesn't work. I might have to manually do the logic
> to create the maps.
>
> Is there a way in  to make this work?
>
> *For example , Use case Customer*
>
> 1 Customer has
>         2 emails
>         3 Addresses
>         2 Telephones
>
> thanks for your help..
> nathan
>