2013-01-15 149 views
0

我期待創建一個主鍵集合(實際上是實體鍵的一對多關係而無需解析引用的實體)。JPA主鍵集合

例如,

@Entity 
public class BigObject { 
    @EmbeddedId 
    private BigObjectId id; 
    // lots of other stuff 
} 

@Embeddable 
public class BigObjectId { 
    //fields here 
} 

@Entity 
public class Referrer { 
    // This won't work since BigObjectId is an embeddable. I would like a join table 
    // REFERRER_BIGOBJECTS with a REFERRER_ID PK foreign key and a BIGOBJECT_ID PK 
    // foreign key. 
    @OneToMany 
    private Set<BigObjectId> bigObjectIds; 
} 

我意識到這似乎擊敗ORM的目的,但它是有益的是能夠通過大對象進行迭代,而無需解決他們的全部(嵌入式ID對象在系統中的其他地方使用)。有沒有辦法做到這一點?

回答