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的

图片描述

回答:

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

以上是 mybatis sql 查询问题 的全部内容, 来源链接: utcz.com/p/170078.html

回到顶部