mybatis种的ResultMap嵌套

mybatis中的返回类嵌套一个list,如何实现?

    <resultMap id="CusMap" type="com.yang.webstarter.entity.SysUser">
        <collection property="books" javaType="java.util.ArrayList" ofType="com.yang.webstarter.entity.UserBook"
                    select="selectUserBook"
                    column="{userId=id}"/>
    </resultMap>

    <select id="selectCusList" resultMap="CusMap">
        select *
        from sys_user
    </select>

    <select id="selectUserBook" resultType="com.yang.webstarter.entity.UserBook">
        select *
        from user_book
        where user_id = #{userId}
    </select>

调用返回

参考:https://www.cnblogs.com/mark5/p/15559640.html

posted @ 2023-03-08 18:22  lin_0110  阅读(169)  评论(0编辑  收藏  举报