6
回答
mybatis 关联关系 处理问题
【腾讯云】学生服务器套餐10元/月 >>>   
<resultMap id="teacher" type="test.Teacher" autoMapping="true">
        <result property="t_id" column="t_id" />
        <result property="t_name" column="t_name" />
        <result property="s_id" column="s_id" />
        <association property="student" column="t_id"  select="getStudentById"/>
    </resultMap>
    
    <select id="getTeacherById" resultMap="teacher">  
        select * from teacher where s_id=#{s_id}    
    </select>
    
     <select id="getStudentById" resultMap="student">  
        select * from student where t_id=#{t_id}    
    </select>
    
    <resultMap id="student" type="test.Student" autoMapping="true">
        <result property="s_id" column="s_id" />
        <result property="s_name" column="s_name" />
        <result property="t_id" column="t_id" />
        <association property="s_Teacher" column="s_id"  select="getTeacherById"/>

    </resultMap>

如果这样配置的话    无论查询student 还是teacher 都是循环查询直接内存溢出     how to resolve it


举报
顶部