xml文件内容:
<resultMap id="OrderAndOtherResultMap" type="com.zyt.cxfq.model.entity.OrderAndAddressAndBrand" >
<id property="id" column="id"></id>
<association property="userorder" javaType="com.zyt.cxfq.model.TUserorder" resultMap="TUserorderResultMap"/>
<association property="orderaddress" javaType="com.zyt.cxfq.model.TOrderaddress" resultMap="TOrderaddressResultMap"/>
<association property="brandinformation" javaType="com.zyt.cxfq.model.BBrandinformation" resultMap="BBrandinformationResultMap"/>
</resultMap>
实体类内容:
public class OrderAndAddressAndBrand {
/**
* sql查询中使用的字段,必须有,否则mybatis只返回一条数据
*/
private String id;
private TUserorder userorder;
private TOrderaddress orderaddress;
private BBrandinformation brandinformation;
<id>节点必须存在,id字段必须存在,否则查询语句只会返回一条数据
sql查询内容:
<select id="getOrderList" resultMap="OrderAndOtherResultMap">
select
UUID() as id,
<include refid="TUserorder_Column_List"/>
,
<include refid="TOrderaddress_Column_List"/>
,
<include refid="BBrandinformation_Column_List"/>
from t_userorder uo left join t_orderaddress oa on uo.T_UserOrderID = oa.T_UserOrderrID
left join b_brandinformation bf on uo.B_BrandInformationID = bf.B_BrandInformationID
<where>
<if test="userid != null">
uo.B_Member_ID = #{userid}
</if>
<if test="state != null">
and uo.OrderState = #{state}
</if>
<if test="orderid != null and orderid != ''">
and uo.T_UserOrderID = #{orderid}
</if>
</where>
</select>
---------------------
作者:tpc1990519
来源:CSDN
原文:https://blog.csdn.net/tpc1990519/article/details/76691505
版权声明:本文为上一个作者原创文章,转载请附上博文链接请询问tpc1990519!