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

2018-06-18 01:11:13来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折


<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语句在数据库运行没有一点问题,不知哪位贤才能解答一二??

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:在IDEA里创建web项目,以及web 项目部署

下一篇:JAVAEE——BOS物流项目14:Linux部署(安装jdk、tomcat、mySQL)