Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 17234 invoked from network); 29 Mar 2007 11:51:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Mar 2007 11:51:59 -0000 Received: (qmail 54107 invoked by uid 500); 29 Mar 2007 11:52:03 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 54088 invoked by uid 500); 29 Mar 2007 11:52:03 -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 54063 invoked by uid 99); 29 Mar 2007 11:52:03 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Mar 2007 04:52:03 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of larry.meadors@gmail.com designates 64.233.182.188 as permitted sender) Received: from [64.233.182.188] (HELO nf-out-0910.google.com) (64.233.182.188) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Mar 2007 04:51:54 -0700 Received: by nf-out-0910.google.com with SMTP id q29so150870nfc for ; Thu, 29 Mar 2007 04:51:33 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:reply-to:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=JtbzPbQY3HecLoDEWvGnMbubpIP4aKxI+P5co0RKs2F9OKT0n4dk9MrmDg9pnSXHEsct8j3ct44khJk00pRbEzgfjM7R2p5jVFGImiRVMoGv18WBsXxX74kXKCRy3d/LFNwvhl7irYJyTrQt4qFdNd4zWF3WVnE/2sp8d/dwhfk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:reply-to:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=W5wraN2n0QqRhzqwNVH2yMQSPBBbR8CFBotaKHH+Q27ZcSOqUpGWSOSvZnVQ4KrF7/obBoS8AROWB0cqM1rKD7FHjBazbECEYGHZFovs/yjpRPYlTRvRPGajNDYEJnX4shKd6rCSgRfGfd9VoauVLJjEUx9/Xd3HrFKKwbHsx7k= Received: by 10.82.104.18 with SMTP id b18mr1302674buc.1175169092763; Thu, 29 Mar 2007 04:51:32 -0700 (PDT) Received: by 10.82.104.6 with HTTP; Thu, 29 Mar 2007 04:51:32 -0700 (PDT) Message-ID: Date: Thu, 29 Mar 2007 05:51:32 -0600 From: "Larry Meadors" Reply-To: lmeadors@apache.org Sender: larry.meadors@gmail.com To: user-java@ibatis.apache.org Subject: Re: Problem creating nested HashMaps using In-Reply-To: <295494f50703281204y2fddd0dfpdf239fea9059671@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <295494f50703280636h1ba647b4jdf0b8434d86c5245@mail.gmail.com> <295494f50703281204y2fddd0dfpdf239fea9059671@mail.gmail.com> X-Google-Sender-Auth: 93f17a9fae2451a2 X-Virus-Checked: Checked by ClamAV on apache.org LOL, I like that.. "trashtable", hahaha. :-D Larry On 3/28/07, Ted Schrader wrote: > Ah, so the hashtables are simply used as buckets in a very limited, > direct scope, i.e. iBATIS --> JasperReports. That's not so bad; > similar to using Maps as parameter objects to iBATIS. I wouldn't > consider this to be a domain model. > > I wish my situation was different: instead of an OrderVO object, I > have to deal with Hashtable. Instead of ItemVO, I deal with > Hashtable. Instead of UserVO, you guessed it...Hashtable. Ugh. > "Trashtable", indeed. > > Good job figuring this out and avoiding the N+1 select, to boot. > > Ted > > On 28/03/07, Utkarsh Ahuja wrote: > > Dear Ted, > > > > The hashtables in hashtables sounds like a really really bad idea > > ....:)....I can totally see that :). The Pojo's do seem to be the best way > > to go and for the most part thats what I have been doing (The tried and > > tested ofcourse). I am doing this as we want to create an independent > > application that hits the same relational database however, we want to be > > able to extract whatever we want from it without being tied down to the > > POJO's(JasperReports) . Simply to eliminate the need for maintenance. > > > > I did try to use XML earlier using ibatis but that did not work out too well > > and it was really slow when I provided an xml document to JasperReports as a > > datasource. > > > > However, I did figure something out late last night. The way to do it is > > something like this. Using groupBy and the resultMap and using a join in the > > select statement > > > > > groupBy="parentProperty1,parentProperty2,parentProperty3,parentProperty4,parentProperty5" > > > > > > > > > > > > > > > > resultMap="namespace.childResultMap"/> > > > > > > > > > > > > > > > > > > > > > > > > This worked and did solve our problem where we could just have a generic > > object to hold the results and we were able to pass it as a datasource to > > jasper reports. Performance wise hashtables work really really well(with > > JasperReports). > > > > Thanks > > Utkarsh > > > > > > > > On 3/28/07, Ted Schrader wrote: > > > I'm not sure about the ultimate answer, but I'm also not sure the > > > following is valid: > > > > > > > > resultMap="childResultMap" select="loadChildren"/> > > > > > > I believe the "resultMap" and "select" attributes are mutually > > > exclusive ("resultMap" for avoiding N+1 selects, and "select" for > > > sub-selects, which in turn have their own resultMaps). > > > > > > Also, at risk of hijacking the thread, I just have to throw in my two > > cents: > > > > > > Call me a coward, but hashtables inside hashtables as a domain model > > > frightens the living daylights out of me. We've just inherited a web > > > app that uses this "design pattern" and we quickly bestowed the > > > honorable title of "trashtable" to the idiom. Perhaps I'm just > > > entrenched in my ways, but I prefer POJOs and the ability to really > > > lean on the compiler (thus my biggest gripe about JSP/Struts tags). I > > > would love to hear about any compelling arguments for the hash-in-hash > > > model in an off-topic thread. > > > > > > Ted > > > > > > On 27/03/07, Utkarsh Ahuja wrote: > > > > Hi, > > > > I am trying to create nested HashMaps something like > > > > > > > > ParentHashMap { > > > > ...... some key value pairs > > > > ...... > > > > childHashMap....some key value pairs > > > > } > > > > > > > > I am doing the following: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > resultMap="childResultMap" select="loadChildren"/> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Can iBatis instantiate and create a HashMap within another HashMap and > > use > > > > the property element as the key for it ? > > > > > > > resultMap="childResultMap" select="loadChildren"/> > > > > > > > > Thanks > > > > Utkarsh > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >