<select id="getUser" parameterType="map" resultType="map"> SELECT id, name, addr FROM user WHERE id = #{id} </select>
以上查询,当addr字段值在数据库中为null时,返回的结果如下:
1 { 2 "id": 1, 3 "name": "test" 4 }
正常我们想要的应该是这样:
1 { 2 "id": 1, 3 "name": "test", 4 "addr": null 5 }
解决办法:
1. 使用实体类进行接收
2.修改application.yml配置
mybatis: configuration: call-setters-on-nulls: true
使用了 mybatis-plus的 配置
mybatis-plus: configuration: call-setters-on-nulls: true
本文来自博客园,作者:天军,原文链接:https://www.cnblogs.com/h2285409/p/17803324.html
标签:configuration,name,resultType,mybatis,null,id,addr From: https://www.cnblogs.com/void--main/p/18289716