ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diran Ayandele <Adediran.Ayand...@Sun.COM>
Subject Re: queryForMap key not working as expected
Date Wed, 08 Mar 2006 18:25:22 GMT
You're probably not defining your key correctly in your 
executeQueryForMap method - thus you're gettting 2 rows with the null 
key and you see the last.

Diran

Guido GarcĂ­a Bernardo wrote:

> Hello, I'm in trouble with this method.
>
> My statement is as simple as:
>    <statement id="foo_query" resultClass="java.util.HashMap">
>    select '1' as key, 'France' as country, 'yes' as eu from dual
>    union
>    select '2' key, 'Spain' as country, 'yes' as eu from dual
>    </statement>
>
> When I do:
>    Map map = getSqlMapExecutor().queryForMap("foo_query", null, "key");
>
> The logs are fine, returning two records:
> DEBUG 18:36:25,390 [TP-Processor5 Connection] - {conn-100007} Connection
> DEBUG 18:36:25,406 [TP-Processor5 PreparedStatement] - {pstm-100008} 
> PreparedStatement:   select '1' as key, 'France' as country, 'yes' as 
> eu from dual  union  select '2' key, 'Spain' as country, 'yes' as eu 
> from dual DEBUG 18:36:25,406 [TP-Processor5 PreparedStatement] - 
> {pstm-100008} Parameters: []
> DEBUG 18:36:25,406 [TP-Processor5 PreparedStatement] - {pstm-100008} 
> Types: []
> DEBUG 18:36:25,437 [TP-Processor5 ResultSet] - {rset-100009} ResultSet
> DEBUG 18:36:25,453 [TP-Processor5 ResultSet] - {rset-100009} Header: 
> [KEY, COUNTRY, EU]
> DEBUG 18:36:25,453 [TP-Processor5 ResultSet] - {rset-100009} Result: 
> [1, France, yes]
> DEBUG 18:36:25,453 [TP-Processor5 ResultSet] - {rset-100009} Result: 
> [2, Spain, yes]
>
> But if I debug into the map, its key is null and there is only one 
> record !
> {null={COUNTRY=Spain, EU=yes, KEY=2}}
>
> Where could be the problem?
> Thank you very much in advance,
> Guido.


Mime
View raw message