//一对一关联查询,以订单为中心关联用户 mapper.xml
定义返回结果集 orders属性含有user对象
<resultMap id="order" type="pojo.Orders">
<id property="id" column="id"/>
<result property="userId" column="user_id"/>
<result property="number" column="number"/>
<result property="createtime" column="createtime"/>
<association property="user" javaType="pojo.User">
<result property="id" column="user_id"/>
<result property="username" column="username"/>
</association>
</resultMap>
<select id="selectOrders" resultMap="order">
select o.id,
o.user_id,
o.number,
o.createtime,
u. username
from orders o
left join user u
on o.user_id = u.id
</select>