mybatis sql 查询问题

今天碰到一个关于mybatis的问题 查询到的数据是null
首先申明,数据库是有相关的数据,并且sql是正确的,但是调用的时候 debug进去发现查出来的list集合是空数据。

   <resultMap id="RevenuePercsResultMap"    type="com.xxx.common.dto.report.RevenuePercsEntity">
    <result property="totalPrice" column="totalPrice" />
    <result property="bussinessType" column="bussinessType"/>
 </resultMap>

<select id="getCommoditySalesTotalPercentage" resultMap="RevenuePercsResultMap" parameterType="com.xxx.common.param.report.GetReportParam">
   select sum(a.`num` * a.price) as totalPrice,o.business_type as bussinessType
    from order_detail a right join `order` o on o.id = a.order_id
    where o.shop_id = #{param.shopId} and (o.business_type = 0 or o.business_type = 1 or o.business_type = 2)
   <if test="param.startTm != null and param.endTm != null and param.startTm != '' and param.endTm != ''">
        and o.create_tm between #{param.startTm} and #{param.endTm}
   </if>
    group by o.business_type
</select>

在java代码里面调用这个查询数据库的方法的时候,方法查出来的数据是:
只有当o.business_type = 2 有显示查到数据,o.business_type = 0 和 o.business_type = 1 都是null的

图片描述

阅读 2.8k
1 个回答

你数据库字段 跟 javabean 的关系在哪?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题