尽管是一对多的信息,但仍然是表对表,所以连接仍然为
select * from user inner join order on user.id=order.id where user.id=#{id}
一对多的封装和一对一不同,尽管仍然是将order中的属性封装到user中,但是order对象为多个,所以需要使用数组list<order> orderList创建
封装好属性后一样需要在xml中进行配置 ,首先在usermap中添加一对多标签
同样需要为oder添加映射标签resultMap在其中添加id等属性字段的映射,然后查询就不会报错了。