我有一个 ValuedCustomer 和 Order,我想在 hibernate 中建立双向关系。我该怎么做呢?谢谢
@Entity
@Table(name="VCUST")
@DiscriminatorValue("VCUST")
@PrimaryKeyJoinColumns({
@PrimaryKeyJoinColumn(name="CUST_ID",referencedColumnName="ID"),
@PrimaryKeyJoinColumn(name="CUST_TYPE",referencedColumnName="TYPE")
})
public class ValuedCustomer extends Customer {
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL,orphanRemoval = true)
@JoinColumn(name = "customer_order", nullable = true)
private Set<Order> orders = new HashSet<>();
}
@Entity
@Table(name=“Order”)
public class Order {
@Id
private int id;
}