这个问题我大概花了2个小时才找到结果
总共需要2个设置
这里是对应springboot中的配置写法
@select("select sum(a) a,sum(b) b from XXX where XXX; ")
Map<String, Object> sumXXX(XXX);
Map map = sumXXX(args);
a | b |
---|---|
NULL | NULL |
期望结果
map : {a:null,b:null}
实际结果
map : null
mybatis.configuration.call-setters-on-nulls=true
这个设置很容易搜索到
并没有变换
测试发现
如果结果是
a | b |
---|---|
1 | NULL |
默认设置时
map : {a:1}
设置mybatis.configuration.call-setters-on-nulls=true
后
map : {a:1,b:null}
第二个设置我并没有google到 可能形容的不准确
我是花了将近2个小时一步步debug找到的
mybatis.configuration.return-instance-for-empty-row=true
这个一起设置才能返回期望结果