Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 7998 invoked from network); 11 Jul 2008 05:21:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Jul 2008 05:21:08 -0000 Received: (qmail 1411 invoked by uid 500); 11 Jul 2008 05:21:02 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 1394 invoked by uid 500); 11 Jul 2008 05:21:02 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 1383 invoked by uid 99); 11 Jul 2008 05:21:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jul 2008 22:21:02 -0700 X-ASF-Spam-Status: No, hits=2.6 required=10.0 tests=DNS_FROM_OPENWHOIS,SPF_HELO_PASS,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Jul 2008 05:20:09 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1KHB3X-0005tQ-6G for user-java@ibatis.apache.org; Thu, 10 Jul 2008 22:20:31 -0700 Message-ID: <18396957.post@talk.nabble.com> Date: Thu, 10 Jul 2008 22:20:31 -0700 (PDT) From: John Dahl To: user-java@ibatis.apache.org Subject: Re: Having two N plus 1 groups In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Nabble-From: clickjohndahl@gmail.com References: <4874BE19.9020100@gmx.de> <18380979.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org Thanks for the solution. Using two query did it and I don't have to worry about N+1 problem here as we need to load only one reportGroup (getReportGroupById) but not their collection. Will try rowhandler later. Thanks once again for quick response. Larry Meadors wrote: >=20 > I don't think you'll be able to accomplish that without using either 2 > queries or a rowhandler. >=20 > RowHandlers are really simple to write (1 method in the interface), > and then you get all the data in one query, and can do pretty much > anything you want with it. >=20 > Larry >=20 >=20 > On Thu, Jul 10, 2008 at 5:36 AM, John Dahl > wrote: >> >> I am having similar problems but can't find any solution. >> Here is my case. >> >> report_group can have many report_types and many reports. No relation >> exists >> for report_type and reports. Here is the result of a query to get a >> report_group. >> >> report_group_id report_id report_type_id >> 100 35 1 >> 100 35 2 >> 100 36 1 >> 100 36 2 >> 100 37 1 >> 100 37 2 >> >> Now, desired result is: >> ReportGroup with >> 3 Report {35, 36, 37} and 3 ReportType {1, 2}. >> >> I have put groupBy=3D"id" in all of the 3 resultMap (report_group, repor= ts, >> report_types), but I am getting a ReportGroup with >> 3 Report {35, 36, 37} >> & 6 ReportType(1, 2, 1, 2, 1, 2) i.e. 6 ReportType object being repeated >> with every Report. >> >> How can I solve the problem? Any help is greatly appreciated. >> >> >> >> Heinrich G=C3=B6tzger wrote: >>> >>> Hello, >>> >>> I'm wondering if iBATS help me for solving _two_ N plus 1 problems >>> within one select: >>> >>> Let's assume a result as follows: >>> >>> main group_A group_b >>> ------------------------------- >>> parent1, child_a1, null >>> parent1, child_a2, null >>> parent1, null, child_b1 >>> parent1, null, child_b2 >>> parent2, child_a4, null >>> parent2, null, child_b3 >>> parent3, child_a5, null >>> parent3, child_a6, null >>> parent3, child_a7, null >>> parent3, null, child_b4 >>> >>> How would I get a list of main-beans with: >>> - parent1: containing list child_a(a1, a2), list child_b(b1, b2) >>> - parent2: containing list child_a(a4), list child_b(b3) >>> - parent3: containing list child_a(a5, a6, a7), list child_b(b4) >>> >>> Group a and group b are not related to each other. They are only relate= d >>> to parent >>> >>> A more convenient solution could be the usage of collection types in th= e >>> result set. This would lead to a collection of group a and one of group >>> b. The resulting main-beans would be the same. >>> Is there some support in iBATIS for collection types? >>> >>> >>> Thanks for some thoughts and some help. >>> >>> Cheers >>> >>> Heinrich >>> >>> >> >> -- >> View this message in context: >> http://www.nabble.com/Having-two-N-plus-1-groups-tp18361780p18380979.htm= l >> Sent from the iBATIS - User - Java mailing list archive at Nabble.com. >> >> >=20 >=20 --=20 View this message in context: http://www.nabble.com/Having-two-N-plus-1-gro= ups-tp18361780p18396957.html Sent from the iBATIS - User - Java mailing list archive at Nabble.com.