public class StuInfo {
private Integer stuId;
private String stuName;
private Integer age;
private String sex;
private String email;
private String mobile;
private String address;
/** 学生详细信息 */
private StudentDetail studentDetail;
查询所有学生信息SQL
<select id="selectAllStuInfo" resultMap="StuInfoResult">
select * from stuInfo
</select>
ResultMap <resultMap id="StuInfoResult" class="StuInfo">
<result property="stuId" column="stuId" />
<result property="stuName" column="stuName" />
<result property="age" column="age" />
<result property="sex" column="sex" />
<result property="email" column="email" />
<result property="mobile" column="mobile" />
<result property="address" column="address" />
<result property="studentDetail" column="studentDetail" select="basic.findHobbyById" />
</resultMap>
根据Id进行查询爱好信息
<select id="findHobbyById" resultClass="StudentDetail"
parameterClass="int">
select * from StudentDetail where
studentDetailId=#studentDetailId#
</select>
页面显示:
<s:property value="#stuInfo.studentDetail.hobby" />