初学Mybatis框架,其实这个是我个人自己通过多表查询延伸想的,为了查询的时候避免查询出不需要的数据。其实学到后面可以用懒加载完成,不必那么繁琐,但这是我还未接触后面知识想到的,单纯的想记录一下。话不多说,先上代码:
//关键映射文件配置
<resultMap id="userAnduserInfo" type="QueryVo">
<association property="user" javaType="User">
<id column="id" property="id"/>
<result column="username" property="username"/>
<result column="birthday" property="birthday"/>
<result column="sex" property="sex"/>
<result column="address" property="address"/>
</association>
<association property="userInfo" javaType="userInfo">
<id column="id" property="id"/>
<result column="height" property="height"/>
<result column="weight" property="weight"/>
<result column="married" property="married"/>
</association>
</resultMap>
//查询语句
<select id="findUserAndUserInfo" resultMap="userAnduserInfo" resu