mybatis一对多

 <resultMap type="entity.Grade" id="GradeResult">
    <id column="gid" jdbcType="INTEGER" property="gid"/>
    <result column="gname" jdbcType="VARCHAR" property="gname"/>
    <result column="gdesc" jdbcType="VARCHAR" property="gdesc"/>
    <!-- 一对多关系 -->
    <!-- <collection property="stus" resultMap="Student.StudentResult"></collection>  -->
    <collection property="stus" ofType="entity.Student">
        <id property="sid" column="sid"/>
        <result property="sname" column="sname"/>
        <result property="sex" column="sex"/>
    </collection>
  </resultMap>


<resultMap type="entity.Student" id="StudentResult">
    <id column="sid" jdbcType="INTEGER" property="sid"/>
    <result column="sname" jdbcType="VARCHAR" property="sname"/>
    <result column="sex" jdbcType="VARCHAR" property="sex"/>
    <!-- 多对一 -->
   <!--  <association property="grade" resultMap="Grade.GradeResult"></association> -->
    <association property="grade" javaType="entity.Grade">
        <id property="gid" column="gid"/>
        <result property="gname" column="gname"/>
        <result property="gdesc" column="gdesc"/>
    </association>
  </resultMap>
posted @ 2017-06-11 17:37  冰冰碎  阅读(141)  评论(0编辑  收藏  举报