You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by eznibe <en...@gmail.com> on 2007/10/09 23:19:27 UTC

resultMap HashMap and with a list

Hi All,

can someone tell me if this can be done...

QRY

Select type, name 
from table
order by type, name

where the result will be

TYPE NAME
type1 aaa
type1 bbb
type2 ccc
type3 axzd


I want a map with 3 Keys (type1, type2, and type3) and the value of each Key
is the list or Names?

can this be done... i tried this and no luck

<resultMap id="get-types" class="java.util.HashMap" groupBy="key">
<result property="key" column="name" />
<result property="val" resultMap="get-names"/>
</resultMap>


<resultMap id="get-names" class="java.util.ArrayList">
<result property="name" resultMap="name" />
</resultMap>


<select id="retrieveRelatedTo" resultMap="get-cnt-cnt-connections">
Select type, name 
from table
order by type, name
</select>


Thanks
-- 
View this message in context: http://www.nabble.com/resultMap-HashMap-and-with-a-list-tf4596974.html#a13125000
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


RE: resultMap HashMap and with a list

Posted by eznibe <en...@gmail.com>.
Because i was looking some xml that do it for me easier

Thks



Arora, Parvinder wrote:
> 
> Why can't you fetch them as a simple list and then iterate over the list
> to create a map?
> 
> ~Parvinder
> 
> -----Original Message-----
> From: eznibe [mailto:enbertran@gmail.com] 
> Sent: Tuesday, October 09, 2007 5:19 PM
> To: user-java@ibatis.apache.org
> Subject: resultMap HashMap and with a list
> 
> 
> Hi All,
> 
> can someone tell me if this can be done...
> 
> QRY
> 
> Select type, name 
> from table
> order by type, name
> 
> where the result will be
> 
> TYPE NAME
> type1 aaa
> type1 bbb
> type2 ccc
> type3 axzd
> 
> 
> I want a map with 3 Keys (type1, type2, and type3) and the value of each
> Key
> is the list or Names?
> 
> can this be done... i tried this and no luck
> 
> <resultMap id="get-types" class="java.util.HashMap" groupBy="key">
> <result property="key" column="name" />
> <result property="val" resultMap="get-names"/>
> </resultMap>
> 
> 
> <resultMap id="get-names" class="java.util.ArrayList">
> <result property="name" resultMap="name" />
> </resultMap>
> 
> 
> <select id="retrieveRelatedTo" resultMap="get-cnt-cnt-connections">
> Select type, name 
> from table
> order by type, name
> </select>
> 
> 
> Thanks
> -- 
> View this message in context:
> http://www.nabble.com/resultMap-HashMap-and-with-a-list-tf4596974.html#a
> 13125000
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/resultMap-HashMap-and-with-a-list-tf4596974.html#a13125201
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


RE: resultMap HashMap and with a list

Posted by "Arora, Parvinder" <PA...@att.com>.
Why can't you fetch them as a simple list and then iterate over the list
to create a map?

~Parvinder

-----Original Message-----
From: eznibe [mailto:enbertran@gmail.com] 
Sent: Tuesday, October 09, 2007 5:19 PM
To: user-java@ibatis.apache.org
Subject: resultMap HashMap and with a list


Hi All,

can someone tell me if this can be done...

QRY

Select type, name 
from table
order by type, name

where the result will be

TYPE NAME
type1 aaa
type1 bbb
type2 ccc
type3 axzd


I want a map with 3 Keys (type1, type2, and type3) and the value of each
Key
is the list or Names?

can this be done... i tried this and no luck

<resultMap id="get-types" class="java.util.HashMap" groupBy="key">
<result property="key" column="name" />
<result property="val" resultMap="get-names"/>
</resultMap>


<resultMap id="get-names" class="java.util.ArrayList">
<result property="name" resultMap="name" />
</resultMap>


<select id="retrieveRelatedTo" resultMap="get-cnt-cnt-connections">
Select type, name 
from table
order by type, name
</select>


Thanks
-- 
View this message in context:
http://www.nabble.com/resultMap-HashMap-and-with-a-list-tf4596974.html#a
13125000
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.