有不理解的地方请评论留言
<resultMap id="empmap" type="employee">
<id column="id" property="id"></id>
<result column="real_name" property="realName"></result>
<result column="sex" property="sex"></result>
<result column="birthday" property="birthday"></result>
<result column="mobile" property="mobile"></result>
<result column="email" property="email"></result>
<result column="position" property="position"></result>
<result column="note" property="note"></result>
<!----一对一关系 select里面写执行该SQL的路径---->
<association property="workCard" column="id" select="com.cx.mapper.WorkCardMapper.selectByEmpId"></association>
<!----多对一关系 select里面写执行该SQL的路径---->
<collection property="taskList" column="id" select="com.cx.mapper.EmpTaskMapper.selectByEmpId" fetchType="eager"></collection>
<!--根据性别的不同 column="sex" 鉴别器 -->
<discriminator javaType="java.lang.Integer" column="sex">
<case value="0" resultMap="mm"></case>
<case value="1" resultMap="fem"></case>
</discriminator>
</resultMap>
<!--下面的两个映射都继承上面的映射,经过鉴别器筛选后 决定使用哪个映射并且使用该映射里面的方法-->
<!-- 女性员工的映射 -->
<resultMap id="fem" type="femaleEmployee" extends="empmap">
<association property="femaleHealthForm" column="id" select="com.cx.mapper.FemaleHealthFormMapper.selectHealthFormByEmpId" ></association>
</resultMap>
<!-- 男性员工的映射 -->
<resultMap id="mm" type="maleEmployee" extends="empmap">
<association property="maleHealthForm" column="id" select=""></association>
</resultMap>