ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Maves <Nathan.Ma...@Sun.COM>
Subject Re: Example of a queryForMap() call
Date Tue, 02 Aug 2005 17:11:29 GMT
Yeah how simple is that.  I got it to work right after I sent the  
email.  I only ran into one small gotcha.  I was trying to use an  
implicit result map so when I tried to pull the value out I was  
getting null.  I assumed that this was because the implicit map was  
not using a java.lang.String to store the key.  I added a resultMap  
that specified the javaType as String and everything worked perfect!

I still might write up a FAQ about this.


Nathan

On Aug 2, 2005, at 10:53 AM, Larry Meadors wrote:

> queryForMap("getStudentNames", parameterMap, "studentId",  
> "studentName");
>
> On 8/2/05, Nathan Maves < Nathan.Maves@sun.com> wrote:
> In the given example below ....
>
>      <select id="getStudentNames" parameterClass="map">
>          select
>              student_id as studentId
>              student_name as studentName
>          from
>              students
>          where
>              student_id in  (
>                  <iterate property="parentIds" conjunction=",">
>                      #studentIds[]#
>                  </iterate>
>              )
>      </select>
>
>
> How could I end up with a Map keyed by studentId and the value be
> their name?
>
> What should be the resultClass?
>
> Is this the correct call?
>
> queryForMap("getStudentNames", parameterMap, "studentId");
>
>
> Once the examples are in I can put them up on the FAQ site.
>
> Nathan
>


Mime
View raw message