//1.实体类
public class User {
private int id;
private String username;
private String password;
private Date birthday;
}
public class Orders {
private int id;
private String orderTime;
private double total;
private User user;
}
select o.id oid,o.ordertime,o.total,o.uid,u.*
from orders o inner join user u
on o.uid=u.id
②. 使用collection一对多
一对多查询的需求:查询一个用户,与此同时查询出该用户具有的订单
public class User {
private int id;
private String username;
private String password;
private Date birthday;
//代表当前用户具备哪些订单
private List orderList;
}
③. 使用collection多对对
多对多查询的需求:查询用户同时查询出该用户的所有角色
public class User {
private int id;
private String username;
private String password;
private Date birthday;
//代表当前用户具备哪些订单
private List orderList;
//代表当前用户具备哪些角色
private List roleList;
}
public class Role {
private int id;
private String rolename;
}