Compound Primary Key in InheritanceType.JOINED [message #645842] |
Mon, 20 December 2010 13:45  |
Eclipse User |
|
|
|
Classic case of a many-to-many association with state, forcing the association class to be an instance. Worse, the association class has an inheritance tree.
Say classes Parent1 and Parent2 have a many-to-many association of class AssocA. And we wish to use JOINED inheritance (awkward sure, but this is legacy).
I have the same problem with or without Id/EmbeddedId classes, so the example shows them without.
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class AssocA {
@Id @ManyToOne public Parent1 p1;
@Id @ManyToOne public Parent2 p2;
@Id public int pk3; //an additional attribute for uniqueness
}
And an association subclass:
@Entity
public class AssocB extends AssocA {
public int additionalAttribute;
}
Eclipselink generates the AssocA table correctly, i.e., with 3 PK columns.
However, the AssocB table is only generated with 1 PK column, PK3.
Is this a bug or improper mapping on my part?
Note that there is no problem using the other inheritance strategies. Of specific interest is that eclipselink DOES recognize the compound primary key for AssocB with TABLE_PER_CLASS inheritance.
|
|
|
|
Powered by
FUDForum. Page generated in 0.85164 seconds