首页 新闻 会员 周边

resultMap实现关联单个对象传递参数的问题

0
悬赏园豆:20 [已关闭问题] 关闭于 2021-01-15 16:04


order的实体和表中都没有member的属性name,只有memberId,现在在SelByid中需要传memberId和name作为条件查询,但是在order中只有memberId可以传,没有name,怎么才能传这个name呢?

大龄初学者兰姐的主页 大龄初学者兰姐 | 初学一级 | 园豆:165
提问于:2021-01-15 13:55
< >
分享
所有回答(1)
0

<resultMap id="map1" type="com.health.pojo.Order">
<id property="id" column="id"/>
<result property="memberId" column="memberId"/>
<result property="orderDate" column="orderDate"/>
<result property="orderType" column="orderType"/>
<result property="orderState" column="orderState"/>
<result property="setmealId" column="setmealId"/>
<association property="member" column="id" resultMap="memberMap" javaType="com.health.pojo.Member"></association>
<association property="setMeal" column="id" resultMap="setmealMap" javaType="com.health.pojo.SetMeal"></association>
</resultMap>
<resultMap id="setmealMap" type="com.health.pojo.SetMeal">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="code" column="code"/>
<result property="helpCode" column="helpCode"/>
<result property="sex" column="sex"/>
<result property="age" column="age"/>
<result property="price" column="price"/>
<result property="remark" column="remark"/>
<result property="attention" column="attention"/>
<result property="img" column="img"/>
</resultMap>
<resultMap id="memberMap" type="com.health.pojo.Member">
<id property="id" column="id"/>
<result property="fileNumber" column="fileNumber"/>
<result property="name" column="name"/>
<result property="sex" column="sex"/>
<result property="idCard" column="idCard"/>
<result property="phoneNumber" column="phoneNumber"/>
<result property="regTime" column="regTime"/>
<result property="email" column="email"/>
<result property="birthday" column="birthday"/>
<result property="remark" column="remark"/>
</resultMap>
<select id="showOrderList" resultMap="map1" parameterType="map">
select o.,m.,s.*
from t_order o left outer join t_setmeal s on o.setmealId=s.id left outer join t_member m on o.memberId=m.id
<where>
<if test="setmealName!=null and setmealName!=''">
and s.name like concat('%',#{setmealName},'%')
</if>
<if test="queryString!=null and queryString!=''">
and (m.name like CONCAT('%',#{queryString},'%') or m.phoneNumber like CONCAT('%',#{queryString},'%'))
</if>
<if test="orderType!=null and orderType!=''">
and o.orderType =#{orderType}
</if>
<if test="orderState!=null and orderState!='' ">
and o.orderState=#{orderState}
</if>
<if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
and (o.orderDate between #{startDate} and #{endDate})
</if>
</where>
</select>

大龄初学者兰姐 | 园豆:165 (初学一级) | 2021-01-15 16:04
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册