ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Meadors" <lmead...@apache.org>
Subject Re: Store results directly into a single HashMap
Date Thu, 10 May 2007 16:36:29 GMT
queryForMap(...)

On 5/10/07, Collin Peters <cadiolis@gmail.com> wrote:
> Hello All,
>
> I'm wondering if iBatis can take a simple query that returns
> name/value pairs (i.e. two columns of many records) and store it into
> a *single* hashmap
>
> So the results of the query look something like:
> name   |   value
> name1 |   value 1
> name2 |   value 2
> name3 |   value 3
> etc....
>
> And at the end I want a single HashMap object with those name/value
> pairs.  My current code looks like this and returns a list of
> HashMaps, and each HashMap has two name/value pairs(name=name1,
> value=value 1, etc...)
>
>
>         <resultMap id="configResult" class="java.util.HashMap">
>                 <result property="name" column="name"/>
>                 <result property="value" column="value"/>
>         </resultMap>
>
>         <select id="loadConfig" parameterClass="java.util.Map"
> resultMap="configResult">
>                 SELECT  name, value
>                 FROM    ....
>         </select
>
> Collin
>

Mime
View raw message