A FailedDeliveryOrder
class has a field with the type of DeliveryOrder
class, while the DeliveryOrder
class has a field with the type of List of ProductDes
class. The DeliveryOrder
field will be embedded in the same table as FailedDeliveryOrder
.
How can I specify a custom name for the table of the List of ProductDes
?
FailedDeliveryOrder.java
@Table(name = "FailedDeliveryOrder")
@Entity
public class FailedDeliveryOrder {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Embedded
private DeliveryOrder deliveryOrder;
public FailedDeliveryOrder() {
}
public FailedDeliveryOrder(DeliveryOrder deliveryOrder) {
this.deliveryOrder = deliveryOrder;
}
//setter and getter
}
DeliveryOrder.java
public class DeliveryOrder {
@Entity
public static class ProductDes {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
public Product() {}
// setter and getter
}
@OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL})
@JoinColumn(
name = "DeliveryOrder_ID",
nullable = false
)
@OrderColumn(
name = "ProductDes_Position",
nullable = false
)
private List<ProductDes> product_descriptions = new ArrayList<Product>();
public DeliveryOrder() {
}
public DeliveryOrder(List<ProductDes> products) {
this.setProduct_descriptions(products);
}
public List<ProductDes> getProduct_descriptions() {
return product_descriptions;
}
public void setProduct_descriptions(List<ProductDes> product_descriptions) {
this.product_descriptions = product_descriptions;
}
}