mybaits,一对多关联查询,无法查询到数据
老师的配置:<mapper namespace="hstc.zhcp.persistence.mapper.TeacherMapper">
<resultMap id="BaseResultMap" type="Teacher">
<id column="tid" jdbcType="INTEGER" property="tid" />
<result column="tname" jdbcType="VARCHAR" property="tname" />
<result column="tgender" jdbcType="CHAR" property="tgender" />
<result column="tposition" jdbcType="VARCHAR" property="tposition" />
<result column="tpassword" jdbcType="VARCHAR" property="tpassword" />
<association column="aId" property="academy" javaType="Teacher" select="hstc.zhcp.persistence.mapper.AcademyMapper.load">
<id column="aid" property="aid"/>
<result column="aname" property="aname"/>
</association>
</resultMap>
<select id="validateLogin" parameterType="int" resultType="Teacher">
SELECT *
FROM teacher
WHERE tid = #{tid}
</select>
<select id="findTeacherByAcademyId" parameterType="int" resultType="Teacher" >
SELECT * FROM teacher WHERE aId = #{aid}
</select>
</mapper>
部门的配置:
<mapper namespace="hstc.zhcp.persistence.mapper.AcademyMapper">
<resultMap id="BaseResultMap" type="Academy">
<id column="aid" jdbcType="INTEGER" property="aid" />
<result column="aname" jdbcType="VARCHAR" property="aname" />
<collection column="aid" property="teacherList" ofType="Teacher" select="hstc.zhcp.persistence.mapper.TeacherMapper.findTeacherByAcademyId" fetchType="lazy"/>
</resultMap>
<select id="load" parameterType="int" resultType="Academy">
SELECT * FROM academy WHERE aid = #{aid}
</select>
</mapper>
两个关系是一对多,从老师查询部门,无法查询到部门的信息,求解决?