我碰到的stackoverflow

出现这种问题,首先需要检查自己的代码;

要么代码小错误;或者逻辑错误;
如果出现循环调用更要仔细检查;

我的问题:
循环调用:一个实体他有自己的父栏目,含有子栏目的list集合;两者结果映射resultMap都调用自身;导致无限循环调用;

错误代码:

<resultMap id="newsLabelMap" type="newsLabel">
    <id property="id" column="id"/>
    <result property="name" column="label_name"/>
    <result property="content" column="label_content"/>

    <association
            property="parent"
            javaType="NewsLabel"
            select="selectNewsLabelByChild"
            column="pid"
    />    
    <collection
        property="child"
        ofType="NewsLabel"
        select="selectNewsLabelByParent"
        column="id"
        javaType="ArrayList"/>
    <select id="selectNewsLabelByChild" resultMap="newsLabelMap">
        select * from newlabel where id=#{pid}
    </select>
    <select id="selectNewsLabelByParent" resultMap="newsLabelMap">
        select * from newlabel where pid=#{id}
    </select>

猜你喜欢

转载自www.cnblogs.com/thegarden/p/12003781.html