mybatis使用的一对多映射关系

1.KeyCustomerFollowUp 实体

package com.xinmt.keycustomer.app.po.keycustomer;



import java.util.Date;
import java.util.List;


import org.springframework.format.annotation.DateTimeFormat;


import com.app.common.entity.BaseEntity;


/**
 * 客户跟进信息
 * @author syn
 *2018年5月9日
 *
 */
public class KeyCustomerFollowUp extends BaseEntity{

private String followUpAddress;//跟进地址

        private KeyCustomerInfo customer;

        private List<FollowUpFile> fileList; //文件集合

}


2.mapper.xml

<resultMap    type="com.xinmt.keycustomer.app.po.keycustomer.KeyCustomerFollowUp" id="customerFollowUpMap">
        <id property="id" column="id" />
        <result column="contact_phone" property="contactPhone" jdbcType="VARCHAR" />
    <result column="follow_up_title" property="followUpTitle" jdbcType="VARCHAR" />
    <result column="follow_up_content" property="followUpContent" jdbcType="VARCHAR" />
        <collection property="customer" ofType="com.xinmt.keycustomer.app.po.keycustomer.KeyCustomerInfo">
           <id property="customerInfoId" column="customer_info_id" />
           <result column="company_name" property="companyName" jdbcType="VARCHAR" />
    <result column="contacts" property="contacts" jdbcType="VARCHAR" />
        </collection>   
        <collection  property="fileList"  ofType="com.xinmt.keycustomer.app.po.keycustomer.FollowUpFile">
           <id property="followUpId" column="follow_up_id" />
    <result column="img_url" property="imgUrl" jdbcType="VARCHAR" />
    <result column="voice_url" property="voiceUrl" jdbcType="VARCHAR" />    
        </collection>
    </resultMap>

<select id="getById" resultMap="customerFollowUpMap" parameterType="java.lang.Long" >
    select c.company_name,c.contacts, b.id,b.contact_phone,b.follow_up_content,b.follow_up_title,m.img_url,m.voice_url 
   from key_customer_follow_up b left join  
   follow_up_file m on b.id=m.follow_up_id 
   left join key_customer_info c on b.customer_info_id=c.id
    where b.id = #{id,jdbcType=BIGINT}

  </select>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值