2
考慮以下JPA實體。我的應用程序實例類必須始終具有4個特殊的Envelope實例的OneToOne引用,但它也有一組0-infinite用戶定義的信封。這甚至有可能嗎?單向和/或雙向引用可能嗎?JPA實體映射爲OneToOne以及OneToMany
@Entity(name = "Application_Instance")
public class ApplicationInstance implements Serializable {
@Id
private int databaseId;
private Envelope accountTransfersEnvelope = new Envelope("Account Transfers");
@OneToOne
private Envelope newTransationsEnvelope = new Envelope("New Transactions");
@OneToOne
private Envelope incomeEnvelope = new Envelope("Income Envelope");
@OneToOne
private Envelope creditCarEnvelope= new Envelope("Credit Card");
@OneToMany
protected Set<Envelope> userEnvelopes = new HashSet<Envelope>();
//rest of class
}