mybatis之-----------------resultmap的使用

    <resultMap id="myMap" type="com.student.demo.domain.Student">
        <id property="id1" column="id"/>
        <result property="names" column="name"/>
        <result property="grades" column="grade"/>
        <collection property="list" ofType="com.student.demo.domain.StudentDetail">
            <id property="id" column="id2"/>
            <result property="address" column="address"/>
            <result property="student_id" column="student_id"/>
            <result property="fathers_name" column="fathers_name"/>
            <result property="mathers_name" column="mathers_name"/>
            <result property="phone_number" column="phone_number"/>
        </collection>
    </resultMap>

    <select id="selectAll" resultMap="myMap">
    SELECT
    s.id,
    s.name,
    s.grade,
    sd.id id2,
    sd.address,
    sd.student_id,
    sd.fathers_name,
    sd.mathers_name,
    sd.phone_number
FROM
    student s,students_detail sd where s.id=sd.student_id
</select>

 

 文件下载在->

 

文件中包括数据库结构,下载地址在【文件中】student压缩包

 

 

posted @ 2020-09-23 13:51  wangt1  阅读(116)  评论(0编辑  收藏  举报