码迷,mamicode.com
首页 > 编程语言 > 详细

Spring Boot+mybatis多表链接查询,重复外键

时间:2018-05-12 03:03:19      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:win   tle   数据库   size   scribe   ati   语句   com   work   


<resultMap id="recMap" type="com.winter.entity.work.RecruitEntity">
<id column="rec_id" property="recId"/>
<result column="rec_name" property="recName"/>
<result column="rec_number" property="recNumber"/>
<result column="education_id" property="educationId"/>
<result column="rec_year" property="recYear"/>
<result column="rec_describe" property="recDescribe"/>
<result column="acceptance_of_disability" property="acceptanceOfDisability"/>
<result column="contacts" property="contacts"/>
<result column="contacts_number" property="contactsNumber"/>
<result column="contacts_email" property="contactsEmail"/>
<result column="pec_time" property="pecTime"/>
<result column="detailed_address" property="detailedAddress"/>
<association property="positionEntity" javaType="com.winter.entity.work.PositionEntity">
<id column="pos_id" property="posId"/>
<result column="pos_name" property="posName"/>
</association>
<association property="salaryEntity" javaType="com.winter.entity.work.SalaryEntity">
<id column="sal_id" property="salId"/>
<result column="sal_name" property="salName"/>
</association>
<association column="rec_province" property="recProvince" javaType="com.winter.entity.RegionEntity">
<id column="reg_id" property="regId"/>
<result column="reg_name" property="regName"/>
<result column="pid" property="pid"/>
</association>
<association column="rec__city" property="recCity" javaType="com.winter.entity.RegionEntity">
<id column="reg_id" property="regId"/>
<result column="reg_name" property="regName"/>
<result column="pid" property="pid"/>
<result column="rec_type" property="recType"/>
</association>
<association column="rec_town" property="recTown" javaType="com.winter.entity.RegionEntity">
<id column="reg_id" property="regId"/>
<result column="reg_name" property="regName"/>
</association>
<association property="companyEntity" javaType="com.winter.entity.work.CompanyEntity">
<id column="com_id" property="comId"/>
<result column="com_name" property="comName"/>
</association>
<collection property="resumeEntities" ofType="com.winter.entity.work.ResumeEntity">
<id column="res_id" property="resId"/>
<result column="res_name" property="resName"/>
</collection>
<collection property="treatmentEntities" ofType="com.winter.entity.work.TreatmentEntity">
<id column="tre_id" property="treId"/>
<result column="tre_name" property="treName"/>
</collection>
</resultMap>

<select id="queryRecAll" resultMap="recMap" parameterType="com.winter.util.ConditionUtil">
select
rec.*,
pos.pos_id,
pos.pos_name,
sal.sal_id,
sal.sal_name,
reg1.reg_id,
reg1.reg_name,
reg2.reg_id,
reg2.reg_name,
reg3.reg_id,
reg3.reg_name,
com.com_id,
com.com_name,
res.res_id,
res.title,
tre.tre_id,
tre.tre_name
from cw_recruit rec
left outer join cw_position as pos on pos.pos_id = rec.pos_id
left outer join cw_salary as sal on sal.sal_id = rec.sal_id
left outer join cw_region as reg1 on reg1.reg_id = rec.rec_province
left outer join cw_region as reg2 on reg2.reg_id = rec.rec_city
left outer join cw_region as reg3 on reg3.reg_id = rec.rec_town
left outer join cw_company as com on com.com_id = rec.com_id
left outer join cw_recres as rrs on rrs.rec_id = rec.rec_id
left outer join cw_resume as res on res.res_id = rrs.res_id
left outer join cw_rectre as rcs on rcs.rec_id = rec.rec_id
left outer join cw_treatment as tre on tre.tre_id = rcs.tre_id
limit #{begin}, #{pageSize}
</select>
结果如下:
RecruitEntity{
recId=1,
recName=‘anme‘,
positionEntity=PositionEntity{...},
resumeEntities=[],
salaryEntity=SalaryEntity{...},
treatmentEntities=[TreatmentEntity{...}],
recProvince=RegionEntity{regId=2, pid=0, regName=‘文城镇‘},
recCity=RegionEntity{regId=2, pid=0, regName=‘文城镇‘},
recTown=RegionEntity{regId=2, pid=0, regName=‘文城镇‘},
}
其中三个重复数据,但是sql语句在数据库运行没有一点问题,不知哪位贤才能解答一二??

Spring Boot+mybatis多表链接查询,重复外键

标签:win   tle   数据库   size   scribe   ati   语句   com   work   

原文地址:https://www.cnblogs.com/wqjbook/p/9027046.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!