1.沿用之前的两张表
明显,一个User可以有多个orders
2需求
根据user.name='王五’查orders
3.在数据库中写出来
SELECT u.`username` u_name, o.id o_id
FROM
orders o,USER u
WHERE
o.`user_id`=u.`id`
AND
u.`username`='王五';
4.创建两个model user_2 ,orders(和前面不一样)
(1)user(将orders包装进来)
public class User_2 {
private int id;
private String name;
private String address;
private List<Orders> ordersList;
public List<Orders> getOrdersList() {
return ordersList;
}
public void setOrdersList(List<Orders> ordersList) {
this.ordersList = ordersList;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void set