订单、订单明细、订单明细详情分别是Order一对多OrderDetail一对一OrderDetailInfo
- Order.java
@OneToMany(mappedBy = "order", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@OrderBy(value = "orderDetailId ASC")
private List<OrderDetail> orderDetailList = new ArrayList<OrderDetail>();
@OrderBy(value = "orderDetailId ASC")
private List<OrderDetail> orderDetailList = new ArrayList<OrderDetail>();
- OrderDetail.java
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "orderId", nullable = false)
private Order order;
@JoinColumn(name = "orderId", nullable = false)
private Order order;
@OneToOne(mappedBy = "orderDetail", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private OrderDetailInfo orderDetailInfo;
private OrderDetailInfo orderDetailInfo;
- OrderDetailInfo.java
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "orderDetailId", nullable = false)
private OrderDetail orderDetail;
@JoinColumn(name = "orderDetailId", nullable = false)
private OrderDetail orderDetail;
各自有自己的主键,OrderDetail中有个orderId外键,OrderDetailInfo中有个orderDetailId外键