Multiple Joins

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple Joins

soussou97
Hi;

I Search an example of code source with mutltiple joins implying lists :

T1 => 1..*T2 => 1..*T3 => 1..1 T4 or any exemple with several tables and java beans and list of objects.

Regards;
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Joins

Larry Meadors-2
Try:

http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+get+around+the+N+Plus+1+selects+problem

 - or (same page, shorter link) -

http://tinyurl.com/ydbn4c

Also, please spend some time looking at the WIKI, almost every new
user question is covered there.

Larry


On 10/19/06, soussou97 <[hidden email]> wrote:

>
> Hi;
>
> I Search an example of code source with mutltiple joins implying lists :
>
> T1 => 1..*T2 => 1..*T3 => 1..1 T4 or any exemple with several tables and
> java beans and list of objects.
>
> Regards;
> --
> View this message in context: http://www.nabble.com/Multiple-Joins-tf2472615.html#a6894554
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Joins

soussou97
Hi Larry;

I see already this example it shows a simple example with  only one join but a multiple Joins (with for example 3 tables : T1 => 1..* T2 => 1..*T3).

Larry Meadors-2 wrote
Try:

http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+get+around+the+N+Plus+1+selects+problem

 - or (same page, shorter link) -

http://tinyurl.com/ydbn4c

Also, please spend some time looking at the WIKI, almost every new
user question is covered there.

Larry


On 10/19/06, soussou97 <dboussebha@yahoo.fr> wrote:
>
> Hi;
>
> I Search an example of code source with mutltiple joins implying lists :
>
> T1 => 1..*T2 => 1..*T3 => 1..1 T4 or any exemple with several tables and
> java beans and list of objects.
>
> Regards;
> --
> View this message in context: http://www.nabble.com/Multiple-Joins-tf2472615.html#a6894554
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Joins

Jeff Butler-2
This really isn't that difficult.  Join your three tables in the query, then do a groupBy on the nested result maps.  Have you tried it?
 
<resultMap id="t1" class="T1Class" groupBy="t1key">
  ...
  <result column="t2Objects" resultMap="t2"/>
</resultMap>
 
<resultMap id="t2" class="T2Class" groupBy="t2key">
  ...
  <result column="t3Objects" resultMap="t3"/>
</resultMap>
 
<resultMap id="t3" class="T3Class">
  ...
</resultMap>
 
You can carry this on for as many tables as you need.

Jeff Butler
 

 
On 10/20/06, soussou97 <[hidden email]> wrote:

Hi Larry;

I see already this example it shows a simple example with  only one join but
a multiple Joins (with for example 3 tables : T1 => 1..* T2 => 1..*T3).


Larry Meadors-2 wrote:

>
> Try:
>
> http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+get+around+the+N+Plus+1+selects+problem
>
>  - or (same page, shorter link) -
>
> http://tinyurl.com/ydbn4c
>
> Also, please spend some time looking at the WIKI, almost every new
> user question is covered there.

>
> Larry
>
>
> On 10/19/06, soussou97 <[hidden email]> wrote:
>>
>> Hi;
>>
>> I Search an example of code source with mutltiple joins implying lists :
>>
>> T1 => 1..*T2 => 1..*T3 => 1..1 T4 or any exemple with several tables and
>> java beans and list of objects.
>>
>> Regards;
>> --
>> View this message in context:
>> http://www.nabble.com/Multiple-Joins-tf2472615.html#a6894554
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
>
>

--
View this message in context: http://www.nabble.com/Multiple-Joins-tf2472615.html#a6911430
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|

RE: Multiple Joins

Patrick.Higgins
This should be in the docs. I wasn't sure if it was supported, so I tried it and it worked. Because it's not obvious that multiple groupBy attributes will work, it should be documented.
-----Original Message-----
From: Jeff Butler [mailto:[hidden email]]
Sent: Friday, October 20, 2006 6:21 AM
To: [hidden email]
Subject: Re: Multiple Joins

This really isn't that difficult.  Join your three tables in the query, then do a groupBy on the nested result maps.  Have you tried it?
 
<resultMap id="t1" class="T1Class" groupBy="t1key">
  ...
  <result column="t2Objects" resultMap="t2"/>
</resultMap>
 
<resultMap id="t2" class="T2Class" groupBy="t2key">
  ...
  <result column="t3Objects" resultMap="t3"/>
</resultMap>
 
<resultMap id="t3" class="T3Class">
  ...
</resultMap>
 
You can carry this on for as many tables as you need.

Jeff Butler
 

 
On 10/20/06, soussou97 <[hidden email]> wrote:

Hi Larry;

I see already this example it shows a simple example with  only one join but
a multiple Joins (with for example 3 tables : T1 => 1..* T2 => 1..*T3).


Larry Meadors-2 wrote:

>
> Try:
>
> http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+get+around+the+N+Plus+1+selects+problem
>
>  - or (same page, shorter link) -
>
> http://tinyurl.com/ydbn4c
>
> Also, please spend some time looking at the WIKI, almost every new
> user question is covered there.
>
> Larry
>
>
> On 10/19/06, soussou97 <[hidden email]> wrote:
>>
>> Hi;
>>
>> I Search an example of code source with mutltiple joins implying lists :
>>
>> T1 => 1..*T2 => 1..*T3 => 1..1 T4 or any exemple with several tables and
>> java beans and list of objects.
>>
>> Regards;
>> --
>> View this message in context:
>> http://www.nabble.com/Multiple-Joins-tf2472615.html#a6894554
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
>
>

--
View this message in context: http://www.nabble.com/Multiple-Joins-tf2472615.html#a6911430
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|

Re: Multiple Joins

Larry Meadors-2
Well put, I couldn't agree more:

http://opensource.atlassian.com/confluence/oss/display/IBATIS/Frequently+Asked+Questions

Thanks in advance! :-)

Larry


On 10/20/06, [hidden email] <[hidden email]> wrote:

>
>
> This should be in the docs. I wasn't sure if it was supported, so I tried it
> and it worked. Because it's not obvious that multiple groupBy attributes
> will work, it should be documented.
>
>
> -----Original Message-----
> From: Jeff Butler [mailto:[hidden email]]
> Sent: Friday, October 20, 2006 6:21 AM
> To: [hidden email]
> Subject: Re: Multiple Joins
>
>
> This really isn't that difficult.  Join your three tables in the query, then
> do a groupBy on the nested result maps.  Have you tried it?
>
> <resultMap id="t1" class="T1Class" groupBy="t1key">
>   ...
>   <result column="t2Objects" resultMap="t2"/>
> </resultMap>
>
> <resultMap id="t2" class="T2Class" groupBy="t2key">
>   ...
>   <result column="t3Objects" resultMap="t3"/>
> </resultMap>
>
> <resultMap id="t3" class="T3Class">
>   ...
> </resultMap>
>
> You can carry this on for as many tables as you need.
>
> Jeff Butler
>
>
>
> On 10/20/06, soussou97 <[hidden email]> wrote:
> >
> > Hi Larry;
> >
> > I see already this example it shows a simple example with  only one join
> but
> > a multiple Joins (with for example 3 tables : T1 => 1..* T2 => 1..*T3).
> >
> >
> > Larry Meadors-2 wrote:
> > >
> > > Try:
> > >
> > >
> http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+get+around+the+N+Plus+1+selects+problem
> > >
> > >  - or (same page, shorter link) -
> > >
> > > http://tinyurl.com/ydbn4c
> > >
> > > Also, please spend some time looking at the WIKI, almost every new
> > > user question is covered there.
> > >
> > > Larry
> > >
> > >
> > > On 10/19/06, soussou97 <[hidden email]> wrote:
> > >>
> > >> Hi;
> > >>
> > >> I Search an example of code source with mutltiple joins implying lists
> :
> > >>
> > >> T1 => 1..*T2 => 1..*T3 => 1..1 T4 or any exemple with several tables
> and
> > >> java beans and list of objects.
> > >>
> > >> Regards;
> > >> --
> > >> View this message in context:
> > >>
> http://www.nabble.com/Multiple-Joins-tf2472615.html#a6894554
> > >> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
> > >>
> > >>
> > >
> > >
> >
> > --
> > View this message in context:
> http://www.nabble.com/Multiple-Joins-tf2472615.html#a6911430
> > Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
> >
> >
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Joins

soussou97
In reply to this post by Jeff Butler-2

Hi Jeff;

How define the javabean CategorisedProductList if two composite objects :

Java Beans:

CollectionCategory  with properties
Integer colid;
String colname;

Category with properties
Integer catid;
String catname;

Product with properties
Integer prodid;
String prodname;

CollectionCategory contains a List of category that contains a list of
product ?

Regards;



Jeff Butler-2 wrote:

>
> This really isn't that difficult.  Join your three tables in the query,
> then
> do a groupBy on the nested result maps.  Have you tried it?
>
> <resultMap id="t1" class="T1Class" groupBy="t1key">
>   ...
>   <result column="t2Objects" resultMap="t2"/>
> </resultMap>
>
> <resultMap id="t2" class="T2Class" groupBy="t2key">
>   ...
>   <result column="t3Objects" resultMap="t3"/>
> </resultMap>
>
> <resultMap id="t3" class="T3Class">
>   ...
> </resultMap>
>
> You can carry this on for as many tables as you need.
>
> Jeff Butler
>
>
>
> On 10/20/06, soussou97 <[hidden email]> wrote:
>>
>>
>> Hi Larry;
>>
>> I see already this example it shows a simple example with  only one join
>> but
>> a multiple Joins (with for example 3 tables : T1 => 1..* T2 => 1..*T3).
>>
>>
>> Larry Meadors-2 wrote:
>> >
>> > Try:
>> >
>> >
>> http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+get+around+the+N+Plus+1+selects+problem
>> >
>> >  - or (same page, shorter link) -
>> >
>> > http://tinyurl.com/ydbn4c
>> >
>> > Also, please spend some time looking at the WIKI, almost every new
>> > user question is covered there.
>> >
>> > Larry
>> >
>> >
>> > On 10/19/06, soussou97 <[hidden email]> wrote:
>> >>
>> >> Hi;
>> >>
>> >> I Search an example of code source with mutltiple joins implying lists
>> :
>> >>
>> >> T1 => 1..*T2 => 1..*T3 => 1..1 T4 or any exemple with several tables
>> and
>> >> java beans and list of objects.
>> >>
>> >> Regards;
>> >> --
>> >> View this message in context:
>> >> http://www.nabble.com/Multiple-Joins-tf2472615.html#a6894554
>> >> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Multiple-Joins-tf2472615.html#a6911430
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
>
>

--
View this message in context: http://www.nabble.com/Multiple-Joins-tf2472615.html#a6941501
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: Multiple Joins

soussou97
In reply to this post by Larry Meadors-2
Hi Larry;

I would like to come back on this subject.
The solution that you propose need to change the javabean as in the link :

CategorisedProductList with properties
Category cat;
List<Product> prodList;

Category with properties
Integer catid;
String catname;

Product with properties
Integer prodid;
String prodname;

whereas the standard implementation is :

Category with properties
Integer catid;
String catname;
List<Product> prodList;

Product with properties
Integer prodid;
String prodname;

I am obliged to add the javabean below to fetch in the base ?

CategorisedProductList with properties
Category cat;
List<Product> prodList;

I think that it is heavy ! there are not other solutions more flexible ?

regards






Larry Meadors-2 wrote
Try:

http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+get+around+the+N+Plus+1+selects+problem

 - or (same page, shorter link) -

http://tinyurl.com/ydbn4c

Also, please spend some time looking at the WIKI, almost every new
user question is covered there.

Larry


On 10/19/06, soussou97 <dboussebha@yahoo.fr> wrote:
>
> Hi;
>
> I Search an example of code source with mutltiple joins implying lists :
>
> T1 => 1..*T2 => 1..*T3 => 1..1 T4 or any exemple with several tables and
> java beans and list of objects.
>
> Regards;
> --
> View this message in context: http://www.nabble.com/Multiple-Joins-tf2472615.html#a6894554
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Joins

Larry Meadors-2
I am not sure what you are asking.

A bean like this would work fine:

Integer catid;
String catname;
List<Product> prodList;

Larry


On 11/10/06, soussou97 <[hidden email]> wrote:

>
> Hi Larry;
>
> I would like to come back on this subject.
> The solution that you propose need to change the javabean as in the link :
>
> CategorisedProductList with properties
> Category cat;
> List<Product> prodList;
>
> Category with properties
> Integer catid;
> String catname;
>
> Product with properties
> Integer prodid;
> String prodname;
>
> whereas the standard implementation is :
>
> Category with properties
> Integer catid;
> String catname;
> List<Product> prodList;
>
> Product with properties
> Integer prodid;
> String prodname;
>
> I am obliged to add the javabean below to fetch in the base ?
>
> CategorisedProductList with properties
> Category cat;
> List<Product> prodList;
>
> I think that it is heavy ! there are not other solutions more flexible ?
>
> regards
>
>
>
>
>
>
>
> Larry Meadors-2 wrote:
> >
> > Try:
> >
> > http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+get+around+the+N+Plus+1+selects+problem
> >
> >  - or (same page, shorter link) -
> >
> > http://tinyurl.com/ydbn4c
> >
> > Also, please spend some time looking at the WIKI, almost every new
> > user question is covered there.
> >
> > Larry
> >
> >
> > On 10/19/06, soussou97 <[hidden email]> wrote:
> >>
> >> Hi;
> >>
> >> I Search an example of code source with mutltiple joins implying lists :
> >>
> >> T1 => 1..*T2 => 1..*T3 => 1..1 T4 or any exemple with several tables and
> >> java beans and list of objects.
> >>
> >> Regards;
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Multiple-Joins-tf2472615.html#a6894554
> >> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Multiple-Joins-tf2472615.html#a7275428
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>