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 20:03:07 GMT
Maybe try it with a result map in the middle so that you're not 
dependent on the db for the column name.

Diran



Guido García Bernardo wrote:

> Diran Ayandele escribió:
>
>> 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.
>
> It sounds probable, but I'm using "key" as the column name for the 
> key, the same name used in the statement...
>    queryForMap("foo_query", null, "key");
>
> Thank you for your fast response,
> guido.
>
>>
>> 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