ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c.ze...@ads.it
Subject Re: Return result as Map
Date Thu, 30 Nov 2006 12:53:22 GMT

Debasish Dutta Roy wrote

> Wed, 21 Jun 2006 12:32:25 -0700
> Map will work.
> 1. You have to mention as java.util.HashMap as has been mentioned by
> Niels. Here point to be noted if you do not give a concrete class
> then iBATIS does not know what to instantiate and should give
> exception, I have received this exception. So I suspect there is
> something else that is wrong before this piece of code is executed.
> 2. Your java code mention which one you want as key and which one as a
> e.g. sqlMap.queryForMap("selectFacilityServiceLookup", null,
> "facility_service_code", "facility_service_desc");
> It simply has to work, I use this everyday.

It works!
Well. here is a similar case: I have to retrieve two columns a-la key -
The type of both the involved columns is NUMBER(10)
Here is the map

      <select id="selectTipiOrizzontali" resultClass="java.util.HashMap">
            from TIPI_DATO
            where FORMATO = 'T'

The query extracts the teo columns for the 24 rows currently stored in the
This is the Java code that exerts the "selectTipiOrizzontali"

        lResult = (Map<Integer, Integer>) lSqlMapClient.queryForMap( "
selectTipiOrizzontali", null, "TIPO_DATO_ID", "TIPO_TABELLA_ID" );

Well, the first use to the iterator Iterator<Integer> on the keySet()

Integer lInteger = lIter.next();

raises the java.lang.ClassCastException: java.math.BigDecimal exception.

Inspection with the debugger confirms that the Map contains 24 pairs
but.... the types are BigDecimal BigDecimal (instead of the expected
Integer). That makes sense because the colums are declared of NUMERIC type.

Is there any way, in the SQL map, to state  that the types of
"TIPO_DATO_ID" and should be considered as javaType="java.lang.Integer"?

View raw message