鉴别器
<!--鉴别器-->
<discrimimator>相当于if判断
<resultMap id="findas" type="com.qf.bean.Student"> <id column="userid" property="userid"></id> <result column="username" property="username"></result> <result column="sex" property="sex"></result> <!--鉴别器--> <discriminator javaType="string" column="sex"> <case value="男" resultMap="boyh"></case> <case value="女" resultMap="girlh"></case> </discriminator> </resultMap> <resultMap id="boyh" type="com.qf.bean.BoyHealth" extends="findas"> <collection property="boyhealths" select="findboyid" column="userid" ></collection> </resultMap> <resultMap id="girlh" type="com.qf.bean.GirlHealth" extends="findas"> <collection property="girlHealths" select="findgirkid" column="userid"></collection> </resultMap> <select id="findboyid" resultType="com.qf.bean.Boy"> select * from boy where bid=#{id} </select> <select id="findgirkid" resultType="com.qf.bean.Gril"> select * from girl where gid=#{id} </select> <select id="findallstudent" resultMap="findas"> select * from student </select>