81,122
社区成员




<resultMap id="ClazzResultMap" type="com.cn.hnust.pojo.ClazzEntity" >
<id column="classID" property="clazzID" jdbcType="INTEGER" />
<result column="className" property="clazzName" jdbcType="VARCHAR" />
<collection property="studentList" column="classID" javaType="ArrayList"
ofType="com.cn.hnust.pojo.StudentEntity" select="getStudentByClassID"/>
</resultMap>
<resultMap id="StudentResultMap" type="com.cn.hnust.pojo.StudentEntity">
<id property="stuID" column="stuID" />
<result property="stuName" column="stuName" />
<result property="stuAge" column="stuAge" />
<result property="stuAddress" column="stuAddress" />
</resultMap>
<select id="getClassByID" resultMap="ClazzResultMap" parameterType="java.lang.Integer" >
select classID,className
from class_t
where classID = #{clazzID}
</select>
<select id="getStudentByClassID" resultMap="StudentResultMap" parameterType="java.lang.Integer" >
select stuID,stuName,stuAge,stuAddress,classID
from student_t
where classID = #{clazzID}
</select>
这种[/quote]
我想的一样,已经实现成功了。最后把分给你,毕竟解决方法是对的 <resultMap id="ClazzResultMap" type="com.cn.hnust.pojo.ClazzEntity" >
<id column="classID" property="clazzID" jdbcType="INTEGER" />
<result column="className" property="clazzName" jdbcType="VARCHAR" />
<collection property="studentList" column="classID" javaType="ArrayList"
ofType="com.cn.hnust.pojo.StudentEntity" select="getStudentByClassID"/>
</resultMap>
<resultMap id="StudentResultMap" type="com.cn.hnust.pojo.StudentEntity">
<id property="stuID" column="stuID" />
<result property="stuName" column="stuName" />
<result property="stuAge" column="stuAge" />
<result property="stuAddress" column="stuAddress" />
</resultMap>
<select id="getClassByID" resultMap="ClazzResultMap" parameterType="java.lang.Integer" >
select classID,className
from class_t
where classID = #{clazzID}
</select>
<select id="getStudentByClassID" resultMap="StudentResultMap" parameterType="java.lang.Integer" >
select stuID,stuName,stuAge,stuAddress,classID
from student_t
where classID = #{clazzID}
</select>
这种[/quote]
我想的一样,已经实现成功了。最后把分给你,毕竟解决方法是对的 <resultMap id="ClazzResultMap" type="com.cn.hnust.pojo.ClazzEntity" >
<id column="classID" property="clazzID" jdbcType="INTEGER" />
<result column="className" property="clazzName" jdbcType="VARCHAR" />
<collection property="studentList" column="classID" javaType="ArrayList"
ofType="com.cn.hnust.pojo.StudentEntity" select="getStudentByClassID"/>
</resultMap>
<resultMap id="StudentResultMap" type="com.cn.hnust.pojo.StudentEntity">
<id property="stuID" column="stuID" />
<result property="stuName" column="stuName" />
<result property="stuAge" column="stuAge" />
<result property="stuAddress" column="stuAddress" />
</resultMap>
<select id="getClassByID" resultMap="ClazzResultMap" parameterType="java.lang.Integer" >
select classID,className
from class_t
where classID = #{clazzID}
</select>
<select id="getStudentByClassID" resultMap="StudentResultMap" parameterType="java.lang.Integer" >
select stuID,stuName,stuAge,stuAddress,classID
from student_t
where classID = #{clazzID}
</select>
这种