Mybatis-3: Got null map while using map as resultType to store result with all null columns.

Created on 18 May 2018  ·  1Comment  ·  Source: mybatis/mybatis-3

MyBatis version

3.4.5

Database vendor and version

MySQL 5.7

Test case or example project

@select("select sum(a) aa,sum(b) bb,sum(c) cc from XXX where XXX; ")
Map<String, Object> sumXXX(XXX);

Map map = sumXXX(args);

result like this below:

aa | bb | cc
-- | --| --
NULL | NULL | NULL

I got a null map,which is not as I expected.

PS:
I tried to set
mybatis.configuration.call-setters-on-nulls=true
This only works for results with at least one NotNull column.

I wondered if it is a similar situation to #62

Steps to reproduce

Expected result

map : {aa:null,bb:null,cc:null}

Actual result

map : null

Most helpful comment

Sorry to bother u guys.
I found that I need one more setting

mybatis.configuration.return-instance-for-empty-row=true

I debugged for about 2 hours before I found out.
Google sucks!
TAT
Also I'm pretty blind that it's mentioned at the bottom of #62 #800

>All comments

Sorry to bother u guys.
I found that I need one more setting

mybatis.configuration.return-instance-for-empty-row=true

I debugged for about 2 hours before I found out.
Google sucks!
TAT
Also I'm pretty blind that it's mentioned at the bottom of #62 #800

Was this page helpful?
0 / 5 - 0 ratings