表列具有值,但是在执行SELECT * FROM t_order之后,一些返回结果为空

时间:2019-04-21 11:17:01

标签: mysql mybatis

表中某些列中有值,但是当在mybatis中使用select sql语句时,大多数列返回值都是空。

在mysql(Navicat)中尝试了类似的sql语句,它正确显示了所有值。

映射器文件如下:

<select id="queryPageInDao" resultType="TOrder">
    SELECT * FROM t_order
    <trim prefix="WHERE " prefixOverrides="AND |OR "> 
        AND del = 0
    <if test="param1.userId != null" >
            AND  user_id = #{param1.userId,jdbcType=INTEGER}
        </if>
        <if test="param1.courseId != null" >
            AND course_id = #{param1.courseId,jdbcType=INTEGER}
        </if>
        <if test="param1.paystatus != null" >
            AND    paystatus = #{param1.paystatus,jdbcType=INTEGER}
        </if>
       <if test="param1.userEmail != null">
           AND    user_email like CONCAT('%',#{param1.userEmail},'%' ) 
       </if>
    </trim>
    <if test="param2.sortField != null and param2.sortField != ''">
        ORDER BY ${param2.sortField}  ${param2.sortDirection}
    </if>
    LIMIT #{param2.startIndex, jdbcType=INTEGER} , #{param2.pageSize, jdbcType=INTEGER} 
    </select>

返回结果如下:

  

[TOrder [id = 38,userId = null,courseId = null,price = 10.01,paystatus = 0,... del = 0],

下表中的数据:

id     userId   courseId   price       del
38        45      44       10.01        0

期待这样的事情

  

[TOrder [id = 38,userId = 45,courseId = 44,price = 10.01,.......

0 个答案:

没有答案