1. 问题修正之前
mapper.xml
<resultMap id="fileConfig" type="demo.model.dto.FileConfigModel">
<id column="i_id" property="id"/>
<result column="c_app_id" property="bizCode"/>
<result column="c_desc" property="bizDesc"/>
<result column="c_suffix" property="fileFormat"/>
<result column="i_max_size" property="fileMaxSize"/>
<result column="c_time" property="createTime"/>
<result column="c_update_time" property="updateTime"/>
</resultMap>
<select id="getFileConfig" parameterType="demo.model.req.GetFileConfigReq"
resultType="demo.model.dto.FileConfigModel">
select c_app_id,c_desc,c_suffix,i_max_size
from file_conf_apply where 1=1
<if test="bizCode != null and bizCode != ''">
and c_app_id LIKE CONCAT(CONCAT('%',#{bizCode}),'%')
</if>
<if test="bizDesc != null and bizDesc != ''">
and c_desc LIKE CONCAT(CONCAT('%',#{bizDesc}),'%')
</if>
limit #{fromIndex},#{pageCount}
</select>
出现的问题是,select执行语句返回的list的size大于0,但是,list里面的对象为null。
2. 问题的解决
目前原理还没了解清楚,如果看到的朋友有知道的话,可以在博文下面留言。问题的解决办法是:
修改select语句中resultType。将resultType修改为resultMap,值为fileConfig。修改后的代码为:
<select id="getFileConfig" parameterType="demo.model.req.GetFileConfigReq"
resultMap="fileConfig">
select c_app_id,c_desc,c_suffix,i_max_size
from file_conf_apply where 1=1
<if test="bizCode != null and bizCode != ''">
and c_app_id LIKE CONCAT(CONCAT('%',#{bizCode}),'%')
</if>
<if test="bizDesc != null and bizDesc != ''">
and c_desc LIKE CONCAT(CONCAT('%',#{bizDesc}),'%')
</if>
limit #{fromIndex},#{pageCount}
</select>
博客指出mapper.xml中select执行语句返回的list的size大于0,但list里对象为null的问题。目前尚未明确问题原理,解决办法是修改select语句中resultType为resultMap,值设为fileConfig。
789

被折叠的 条评论
为什么被折叠?



