标题:mybaits,一对多关联查询,无法查询到数据
取消只看楼主
asdwchen
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2015-7-30
结帖率:50%
已结贴  问题点数:20 回复次数:0 
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>

两个关系是一对多,从老师查询部门,无法查询到部门的信息,求解决?
搜索更多相关主题的帖子: 查询 Teacher result property select 
2017-10-15 15:04



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-481431-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.977123 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved