mybatis 查询 数据库字段为null 返回map 接收不到字段

mybatis两种查询方式 一个是用resultMap 一个是用实体类 entity

1. resultMap

    <resultMap type="java.util.HashMap" id="deptsubmitList">
        <result property="count" jdbcType="VARCHAR" column="count"/>
        <result property="number" jdbcType="VARCHAR" column="number"/>
    </resultMap>

<!-- 查询列表 -->
    <select id="queryDeptUtils" parameterType="java.util.HashMap" resultMap="deptsubmitList">
         <![CDATA[
            select 
               COUNT(id) count,
               (CASE when number is null then 0 else number end ) as number 
            from t_f_submit
         ]]>
         <where>
          <if test="basicid != null and basicid != ''">
            <![CDATA[ 
                 and basicid = #{basicid ,jdbcType=VARCHAR }
             ]]>    
          </if>
          <if test="deptname != null and deptname != ''">
            <![CDATA[ 
                 and deptname = #{deptname ,jdbcType=VARCHAR }
             ]]>    
          </if>
         </where>
    </select>

 

2.实体类entity

<select id="queryFileListCount" parameterType="java.util.HashMap" resultType="com.centit.cmip.main.entity.response.ResponseImgFileBean">
        SELECT
             COUNT(1) COUNT
        FROM
            t_file f
        LEFT JOIN 
            t_dic d ON f.file_code = d.dic_code
        <where>
            f.file_status=0
            <if test="id != null and id != ''">
                <![CDATA[
            AND    f.id = #{id,jdbcType=VARCHAR}
                ]]>
            </if>
        </where>
        ORDER BY f.file_createtime DESC
    </select>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值