You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by er...@aftenposten.no on 2005/08/30 13:51:43 UTC

How to force Integer instead BigDecimal with queryForMap for the value part ?

Hi there!
 
I have a queryForMap like this:
 
HashMap codes = (HashMap) sqlMap.queryForMap("retrieveAdminUserAccessCodes", "testUser", "CODE", "VALUE"));
 
And the query like this:
 
    <select id="retrieveAdminUserAccessCodes" resultClass="java.util.HashMap" parameterClass="String">
        select
          CODE,
          VALUE
        from ADMINUSERACCESS
        where ADMINUSERNAME = #value#
    </select>
 
 
VALUE is NUMBER(5) in a Oracle 9.2 database, when I get it back, codes, 
the VALUE part is of type BigDecimal, is it possible to get it as an Integer instead ? hmm
 
Or is it other ways to do this in a better way ?
 
 
Thanks!
Erlend

Re: How to force Integer instead BigDecimal with queryForMap for the value part ?

Posted by Larry Meadors <la...@gmail.com>.
A couple of options:
 1) use resultMap instead of resultClass
 2) use a bean instead of a Map

Using resultClass=Map, you get whatever JDBC sends back - which in
this case is a BigInteger.

My vote would be to use both a bean and a result map - the behavior is
much more predictable, and you'll get slightly better performance.

Larry


On 8/30/05, erlend.bjorge@aftenposten.no <er...@aftenposten.no> wrote:
>  
> Hi there! 
>   
> I have a queryForMap like this: 
>   
> HashMap codes = (HashMap)
> sqlMap.queryForMap("retrieveAdminUserAccessCodes",
> "testUser", "CODE", "VALUE")); 
>   
> And the query like this: 
>   
>     <select id="retrieveAdminUserAccessCodes"
> resultClass="java.util.HashMap" parameterClass="String">
>         select
>           CODE,
>           VALUE
>         from ADMINUSERACCESS 
>         where ADMINUSERNAME = #value#
>     </select> 
>   
>   
> VALUE is NUMBER(5) in a Oracle 9.2 database, when I get it back, codes, 
> the VALUE part is of type BigDecimal, is it possible to get it as an Integer
> instead ? hmm 
>   
> Or is it other ways to do this in a better way ? 
>   
>   
> Thanks! 
> Erlend