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 George Dawoud <gd...@real.com> on 2007/08/14 03:28:49 UTC

Map of Lists

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
George		


Re: AW: Map of Lists

Posted by George Dawoud <gd...@real.com>.
I have not, that was my next on the list if there is no way to do it  
in XML

G

On Aug 13, 2007, at 11:54 PM, Normad2 wrote:

> Hi George,
>
> have you allready tried to implement a RowHandler?
> public class TestRowHandler implements RowHandler {
>     private Map<Type, Value> map = new HashMap<Type, Value>();
>
>     public void handleRow(Object valueObject) {
>         Entity row = (Entity)valueObject;
>         map.put(row.class, row);
>     }
>
>     public Map<Type, Value> getMap(){
>         return this.map;
>     }
> }
>
> Then you can use it like this:
> TestRowHandler rh = new TestRowHandler();
> sqlMapClient().queryWithRowHandler("your.statementid", rh);
> rh.getMap();
>
> Best regards, Tilo
>
> Von: George Dawoud [mailto:gdawoud@real.com]
> Gesendet: Dienstag, 14. August 2007 03:29
> An: user-java@ibatis.apache.org
> Betreff: Map of Lists
>
> 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
> George
>



George Dawoud, Lead Software Development Engineer
Core Applications and Platform Services
RealNetworks

Phone:  206.892.6311
Fax:      206.674.3586

"Programming today is a race between software engineers striving to  
build bigger and better idiot-proof programs, and the universe trying  
to build bigger and better idiots. So far, the universe is winning."  
- Rick Cook




AW: Map of Lists

Posted by Normad2 <no...@gmx.de>.
Hi George,
 
have you allready tried to implement a RowHandler?

public class TestRowHandler implements RowHandler {
    private Map<Type, Value> map = new HashMap<Type, Value>();
 
    public void handleRow(Object valueObject) {
        Entity row = (Entity)valueObject;
        map.put(row.class, row);
    }
 
    public Map<Type, Value> getMap(){
        return this.map;
    }
}

 
Then you can use it like this:

TestRowHandler rh = new TestRowHandler();
sqlMapClient().queryWithRowHandler("your.statementid", rh);
rh.getMap();

 
Best regards, Tilo

  _____  

Von: George Dawoud [mailto:gdawoud@real.com] 
Gesendet: Dienstag, 14. August 2007 03:29
An: user-java@ibatis.apache.org
Betreff: Map of Lists


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
George