我有 2 个表员工和订单:控制台屏幕_执行前 现在我正在尝试映射列表集合以获取每个员工的所有订单。我的映射:
@Entity
@Table(name = "employees", schema = "public")
public class Employees implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 1885071569771542035L;
private short employeeid;
//...
private List<Orders> ordersList;
@OneToMany(mappedBy = "employees")
public List<Orders> getOrders() {
return ordersList;
}
public void setOrders(List<Orders> orders) {
this.ordersList = orders;
}
.
@Entity
@Table(name = "orders", schema = "public")
public class Orders implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 405644896073449066L;
private short orderid;
//...
private Employees employees;
@ManyToOne
public Employees getEmployees() {
return employees;
}
public void setEmployees(Employees employees) {
this.employees = employees;
}
public Orders() {
}
public Orders(short orderid) {
this.orderid = orderid;
}
但不幸的是,我什么也没有。我一直在尝试检测对数据库的 sql 查询,我认为 hibernate 创建了新列:sql result
大概需要参考:
orders0_.employeeid as employeeid1_0_,
不
orders0_.employees_employeeid as employees15_1_0_,
但我不知道如何强迫他这样做。(我正在使用 postgresql)