References to subclass implemented as FK to superclass [message #645873] |
Mon, 20 December 2010 21:31 |
Rich MacDonald Messages: 18 Registered: December 2010 |
Junior Member |
|
|
(Apologies for not being able to find a pre-existing bug report. for this, as it is fairly fundamental and should exist. Or perhaps there is a good technical reason for the chosen shortcut. I'm just not good yet at eclipselink search criteria.)
3 Entity classes, A, B and C:
@Inheritance(strategy=InheritanceType.JOINED)
@Entity class A{}
@Entity class B extends A{}
@Entity class C{
public B b;
}
Not showing primary keys etc.
Problem:
eclipselink creates the FK constraint for C.b on table C that points to the PK on table A. This is incorrect. The FK should point to the PK on table B.
Insertion order into the dbase is table A, then table C, then table B. This is legal due to the prior problem, but it is incorrect: Insertion order should be table A, table B, then table C. IOW, "inheritance-first, relationship-second", rather than "relationship-first, inheritance-second".
The result is that if the dbase is existing and has the C.b FK constraint defined correctly, then it is impossible to model this relationship.
Note that this error also occurs if C.b is defined as @ManyToOne, @Id, etc.
Surely this issue is well-known. Any background and links appreciated,
|
|
|
|
Powered by
FUDForum. Page generated in 0.02779 seconds