Return-Path: Mailing-List: contact ibatis-user-java-help@incubator.apache.org; run by ezmlm Delivered-To: mailing list ibatis-user-java@incubator.apache.org Received: (qmail 98602 invoked by uid 99); 17 Jan 2005 21:46:01 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=RCVD_BY_IP,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of clinton.begin@gmail.com designates 64.233.184.203 as permitted sender) Received: from wproxy.gmail.com (HELO wproxy.gmail.com) (64.233.184.203) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 17 Jan 2005 13:46:00 -0800 Received: by wproxy.gmail.com with SMTP id 68so787599wri for ; Mon, 17 Jan 2005 13:45:57 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=l6Gptjsvprj0+fepV0KYziwqEiBWyfFkdQPo+7ktmAK0EGAv44we8K4FPSdCFJCcz+ppQGjhAHsBwpRL8vTiSnsjflb3uNfyM/gyTcd/h6y4K3HzYBf6EjABHLaOpVtSYlkRydlMiF7iDeJb5TVAX9eAyTytcGZAOZBv/2a1ITY= Received: by 10.54.50.52 with SMTP id x52mr298184wrx; Mon, 17 Jan 2005 13:45:57 -0800 (PST) Received: by 10.54.33.38 with HTTP; Mon, 17 Jan 2005 13:45:57 -0800 (PST) Message-ID: <16178eb105011713456d17294e@mail.gmail.com> Date: Mon, 17 Jan 2005 14:45:57 -0700 From: Clinton Begin Reply-To: cbegin@ibatis.com To: ibatis-user-java@incubator.apache.org Subject: Re: solution for N+1 selects In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: X-Virus-Checked: Checked Hmmm... I can see we really need good documentation around this. By simple nature of a join, you MUST use groupBy. Otherwise you'll end up with too many parent objects. You can use queryForList or queryForObject with the solution, as long as the latter only returns a single parent object. Regardless, you can use the resultMap and groupBy independently as required. You just combine them to eliminate repeating groups for a complex object graph. Cheers, Clinton On Mon, 17 Jan 2005 16:16:42 -0500, Tim_Hammar@mcnichols.com wrote: > > I'm having trouble implementing the 2.0.9 N+1 solution. The example posted > on the wiki deals with a groupBy relationship. Is this the only situation > where the fix applies? I have a simple nested 1:M relationship that I would > love to used this new feature with. Presently I am using the old method of > using a "select " parameter in the result element of my resultMap. I have > replaced this parameter with a "resultMap" parameter. Of course I have > changed the SQL to join the necessary tables. Must I change my query to a > QueryForList and build my result manually or should I be able to use the > same queryForObject that I was using before? I am getting an > executeQueryForObject returned too many results exception. > _______________________________________ > Tim Hammar > Senior Programmer Analyst > McNichols Company > 5501 W. Gray Street, Tampa, FL 33609-1007 > P.O. Box 30300, Tampa, FL 33630-3300 > Local: 813-282-3828, ext. 2419 > Fax: 813-287-8387 > tim.hammar@mcnichols.com > www.mcnichols.com