Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 38329 invoked from network); 5 Apr 2007 21:24:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Apr 2007 21:24:30 -0000 Received: (qmail 9904 invoked by uid 500); 5 Apr 2007 21:24:34 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 9888 invoked by uid 500); 5 Apr 2007 21:24:34 -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 9877 invoked by uid 99); 5 Apr 2007 21:24:34 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Apr 2007 14:24:34 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of mail.micke@gmail.com designates 66.249.92.172 as permitted sender) Received: from [66.249.92.172] (HELO ug-out-1314.google.com) (66.249.92.172) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Apr 2007 14:24:27 -0700 Received: by ug-out-1314.google.com with SMTP id m2so1104406ugc for ; Thu, 05 Apr 2007 14:24:05 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=s4e8m3FXTlxw/i+0xtS2aBCibQOFH2bWHvS6ioEVcCMPmKImKEg6tqILd0JhnE2o5Dp/iUbENj513Hu5RmAYA27n5W7e0Vk3Da9nqZl1HECvxVTI3nql2ZxT3iEYuziA6taMNZzDOxrjM3ClDkGYktPql5vO0l2BohVj2c3Dfls= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=S9DrHZIoOkNUFoKv9fA5QncV9yyauDisGie9WpG0KkJD5+JZpDH9UhmBP3h9RmtyWTDRbKukGrmb1O2TYfq6y9AbbhOFLJBpvK0wASsKZloEKSdkuyLmVthkDSQ7SRXbmligw+3hZWmT0wy524Fq+wGnTsjdAszaQOVnenutSsw= Received: by 10.67.76.16 with SMTP id d16mr2456583ugl.1175808245573; Thu, 05 Apr 2007 14:24:05 -0700 (PDT) Received: by 10.67.18.20 with HTTP; Thu, 5 Apr 2007 14:24:05 -0700 (PDT) Message-ID: <8eed5c5b0704051424l34c68aa9k8ae6d34af09b7a4@mail.gmail.com> Date: Thu, 5 Apr 2007 22:24:05 +0100 From: "Mikael Andersson" To: user-java@ibatis.apache.org Subject: Re: Mapping reuslt to to java.util.Map with dynamic key(from column), possible? In-Reply-To: <7E4302A18925394BAC32C7AD1ABE75D4017BF983@CNET6.cnet.cnwk> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_26483_8242369.1175808245519" References: <8eed5c5b0704050628q13a160cub8586d9cf461e75e@mail.gmail.com> <7E4302A18925394BAC32C7AD1ABE75D4017BF983@CNET6.cnet.cnwk> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_26483_8242369.1175808245519 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Pretty cool feature which I didn't know about :), thanks for the tip. Could you give an example how the queryForMap feature can be used with a nested resultMap, googled a bit and only found how to use it to populate a Map instead of a List as the result of calling a select from the DAO. Thanks, Mike On 05/04/07, Daniel Pitts wrote: > > I think its called queryForMap :-) > > ------------------------------ > *From:* Mikael Andersson [mailto:mail.micke@gmail.com] > *Sent:* Thursday, April 05, 2007 6:28 AM > *To:* user-java@ibatis.apache.org > *Subject:* Mapping reuslt to to java.util.Map with dynamic key(from > column), possible? > > Hi > > I wonder if it is possible to populate a Map via a resultMap so that the > key is the value from a column and the value the value of another column? > > I read how about to create a Map with pre specified key values in the PDF > documentation, but I couldn't find how to use dynamic key value. > > public class MyVO{ > private int id; > private Map properties; > > // getters and setters ... > } > > Table design : > ID | type | value | > ------------------------ > 1 | xx | val1 | > 1 | xy | val2 | > 1 | yx | val3 | > 1 | yy | val4 | > > > > > > > > ????? > > > With the above table data I would like to have one MyVO object with a map > containing the following (type column dictates map key): > [ > key="xx" value="val1" > key="xy" value="val2" > key="yx" value="val3" > key="yy" value="val4" > ] > > Cheers, > Mike > > ------=_Part_26483_8242369.1175808245519 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi

Pretty cool feature which I didn't know about :), thanks for the tip.

Could you give an example how the queryForMap feature can be used with a nested resultMap, googled a bit and only found how to use it to populate a Map instead of a List as the result of calling a select from the DAO.

Thanks,
 Mike

On 05/04/07, Daniel Pitts <Daniel.Pitts@cnet.com> wrote:
I think its called queryForMap :-)


From: Mikael Andersson [mailto:mail.micke@gmail.com]
Sent: Thursday, April 05, 2007 6:28 AM
To: user-java@ibatis.apache.org
Subject: Mapping reuslt to to java.util.Map with dynamic key(from column), possible?

Hi

I wonder if it is possible to populate a Map via a resultMap so that the key is the value from a column and the value the value of another column?

I read how about to create a Map with pre specified key values in the PDF documentation, but I couldn't find how to use dynamic key value.

public class MyVO{
private int id;
private Map<String,String> properties;

// getters and setters ...
}

Table design :
ID | type | value |
------------------------
1  | xx    | val1   |
1  | xy    | val2   |
1  | yx    | val3   |
1  | yy    | val4   |

<resultMap class="MyVO" id="map1">
<result property="id" column="ID"/>
<result property="properties" resultMap="map2"/>
</resultMap>

<resultMap class="java.util.Map" id="map2">
?????
</resultMap>

With the above table data I would like to have one MyVO object with a map containing the following (type column dictates map key):
[
key="xx" value="val1"
key="xy" value="val2"
key="yx" value="val3"
key="yy" value="val4"
]

Cheers,
 Mike

------=_Part_26483_8242369.1175808245519--