ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niels Beekman" <n.beek...@wis.nl>
Subject RE: More complex example of a queryForMap call
Date Thu, 04 Aug 2005 20:45:13 GMT
I believe so yes, the docs say:

The value of the map can either be the entire employee object, or
another property from the employee object as specified in the optional
second parameter called valueProperty.

So when you do not specify the valueProperty-property it returns
Student-objects otherwise the specified property is retrieved from each
Student-object.

The docs do not provide a complete example but are pretty clear to me
about queryForMap(), didn't try it though :)

Niels

-----Original Message-----
From: Nathan Maves [mailto:Nathan.Maves@Sun.COM] 
Sent: donderdag 4 augustus 2005 21:01
To: user-java@ibatis.apache.org
Subject: Re: More complex example of a queryForMap call

I would hope it is that simple but that leads me to ask about the  
last parameter of the

queryForMap(String statementName, Object parameterObject, String  
keyProperty, String valueProperty);


When using it with your below example would

queryForMap("studentStatement", null, "id", "fname");

return a Map of

1 - Niels
2 - Nathan

On Aug 4, 2005, at 12:29 PM, Niels Beekman wrote:

> I would say:
>
> <select id="studentStatement" resultClass="Student">
>   SELECT id, fname, lname
>   FROM students
> </select>
>
> queryForMap("studentStatement", null, "id");
>
> this would result in for example:
>
> 1 - Student1
> 2 - Student2
>
> Or is this too simpleminded?
>
> Niels
>
> -----Original Message-----
> From: Nathan Maves [mailto:Nathan.Maves@Sun.COM]
> Sent: donderdag 4 augustus 2005 18:09
> To: user-java@ibatis.apache.org
> Subject: More complex example of a queryForMap call
>
> Given a student table....
>
> id,fname,lname....
>
>
> how would you make the call to return a Map of Students keys on the
> studentId?
>
> I think the manual is a bit confusing and I am going to create a wiki
> on the topic.
>
> Nathan
>
>


Mime
View raw message