坑:
使用Mybatis查询tinyint(1)字段数据,返回值为Map类型,那么tinyint(1)的数据默认会转化为boolean类型数据.
<select id="queryUserAgentPage" resultType="java.util.Map">
SELECT
a.agent_id agentId,
a.oem_id oemId,
a.is_self_support isSelfSupport,
a.company,
a.belong,
c.company belongAgentName,
a.level,
ifnull(a.status,0) status,
ifnull(a.check_status,0) checkStatus,
a.create_time createTime,
a.vip_time vipTime,
b.username,
b.last_login_time lastLoginTime
FROM
fb_user_agent a
INNER JOIN
fb_user_base b
ON a.base_id = b.base_id
left join fb_user_agent c ON c.agent_id=a.belong
WHERE
b.is_del=0
<include refid="agentCondtionWhere" />
ORDER BY a.id desc
LIMIT #{startNum},#{pageSize}
</select>
上面 sql中的字段 status, 由于返回的类型是Map, 返回成boolean, 由于status不止0,1这两个值,所有不希望返回成boolean类型
解决方案:
ifnull(a.status,0) status,
或者改写成pojo类型
resultType="com.pojo">