Search code examples
javamigrationibatismybatis

MyBatis is not returning column with null value


I am having query which return java.util.HashMap. It return hashmap when query return with 1 or more row, however when query return with 0 rows, I am getting list of null i.e. [null]. This was not the case in IBatis. In IBatis when 0 rows were return it returned with hashmap having list i.e. [Map(columnName1:null,columnName12:null) as return value.

is there any configuration that I can do to get same result?

My Mybatis configuration xml

<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD SQL Map Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
    <setting name="jdbcTypeForNull" value="NULL"/>
</settings>
<typeAliases>
</typeAliases>

<mappers>
    <mapper resource="Mapper.xml" />
    <mapper resource=".." />

</mappers>
</configuration>

My Mapper.xml :

  <select id="select__XR_SEGMENT_IDENTIFIER__By__SEGMENT_SEC_ID" parameterType="java.math.BigDecimal" resultType="java.util.HashMap">
    select 
        a1 , b2 , c3
        , d4 , e5
        , f6, g7
    from 
        abc as left join xyz xy on as.a = xyz.a
    where 
        as.a = #{value}
        and as.FLAG_ACTIVE = 'Y'
  </select>

any help appreciated.

Thanks , Swanand


Solution

  • Seems 3.2 version will have a setting for that.

    Have a look at: http://code.google.com/p/mybatis/issues/detail?id=377