一个resultMap里面有两个association时会报错的解决方案

resultMap:

另外两个association也写成resultMap的形式:

记录下在学习springboot + mybatis + maven项目时出现的问题。。

这个是sql <select id="findCustomersWithDepartment" resultMap="customerResultMap1"> select tscbi.name, tscfi.project_code, tscfi.department AS department_name FROM customer tscbi JOIN family tscfi ON tscbi.customer_id = tscfi.customer_id inner join doctor tschd ON tscfi.project_code = tschd.projectcode AND tscbi.name = tschd.doctor_name where tscfi.project_code = #{projectcode} and tscfi.association_type in ('3','4') and (tscfi.cf_id IS NULL OR tscfi.customer_family_id = tscfi.cf_id) and tschd.association_type!='1' <if test="name != null and name != ''"> and instr(tschd.doctor_name, #{name}) </if> group by tscfi.department,tscbi.name </select> <resultMap id="customerResultMap1" type="com.slup.customer.portrait.entity.response.Customer" autoMapping="true"> <id property="name" column="name"/> <collection property="list" javaType="java.util.List" ofType="com.slup.customer.portrait.entity.response.Customer" column="{name=name,project_code=project_code,department_name=department_name}" select="selectFileCategoryByFileId1"> <collection property="departments" ofType="com.slup.customer.portrait.entity.response.Department" resultMap="departmentResultMap"/> <collection property="doctors" ofType="com.slup.customer.portrait.entity.response.Doctor" resultMap="doctorResultMap"/> </collection> </resultMap> <select id="selectFileCategoryByFileId1" resultType="com.slup.customer.portrait.entity.response.Customer"> select basesub.department_name as name, basesub.customer_id,AES_DECRYPT(UNHEX(basesub.mobile),"SlupjulysxSGWLXN") as mobile ,basesub.project_code, basesub.customer_name,basesub.department_name,basesub.association_type, tschd.increment_id,tschd.doctor_name,tschd.doctor_technical_title,tschd.doctor_academic_title,tschd.doctor_introduction,tschd.dept_name from (SELECT tscfi.project_code, tscbi.customer_id , tscbi.name AS customer_name, tscbi.mobile , tscfi.department AS department_name, tscfi.association_type FROM customer tscbi JOIN family tscfi ON tscbi.customer_id = tscfi.customer_id where tscfi.project_code = #{projectcode} and tscfi.association_type in ('3','4') and tscbi.name =#{name} and tscfi.department=#{department_name} and (tscfi.cf_id IS NULL OR tscfi.customer_family_id = tscfi.cf_id)) basesub left join doctor tschd ON #{projectcode} = tschd.projectcode AND #{name} = tschd.doctor_name AND #{department_name} = tschd.departname and tschd.association_type!='1' </select> <resultMap id="departmentResultMap" type="com.slup.customer.portrait.entity.response.Department" autoMapping="true"> <id property="mobile" column="mobile"/> <result property="name" column="customer_name"/> <result property="customerId" column="customer_id"/> <result property="mobile" column="mobile"/> <result property="projectCode" column="project_code"/> <result property="departmentName" column="department_name"/> </resultMap> <resultMap id="doctorResultMap" type="com.slup.customer.portrait.entity.response.Doctor" autoMapping="true"> <id property="incrementId" column="increment_id"/> <result property="doctorName" column="doctor_name"/> <result property="deptName" column="dept_name"/> <result property="doctorTechnicalTitle" column="doctor_technical_title"/> <result property="doctorAcademicTitle" column="doctor_academic_title"/> <result property="doctorIntroduction" column="doctor_introduction"/> </resultMap> 这个是实体 @Data @JsonInclude(value = JsonInclude.Include.NON_NULL) public class Customer { private String name; private List<Department> departments; // 客户关联的部门列表 private List<Doctor> doctors; private List<Customer> list; } @Data @JsonInclude(value = JsonInclude.Include.NON_NULL) public class Department { private String projectCode; private String departmentName; private String name; private String customerId; private String mobile; private List<Doctor> doctors; // 该部门下关联的医生列表 } @Data @JsonInclude(value = JsonInclude.Include.NON_NULL) public class Doctor { private String incrementId; private String doctorName; private String deptName; private String doctorTechnicalTitle; private String doctorAcademicTitle; private String doctorIntroduction; } 为什么除了name 别的都没有数据
最新发布
07-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值