Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Compound Primary Key in InheritanceType.JOINED(Failed PK mapping for subclasses when superclass PK is compound)
Compound Primary Key in InheritanceType.JOINED [message #645842] Mon, 20 December 2010 18:45 Go to next message
Rich MacDonald is currently offline Rich MacDonaldFriend
Messages: 18
Registered: December 2010
Junior Member
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.
Re: Compound Primary Key in InheritanceType.JOINED [message #647116 is a reply to message #645842] Tue, 04 January 2011 16:27 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Odd. Seems to be a bug in the DDL generation of EclipseLink. Please log the bug and vote for it.

As a workaround you can use a script to define your DDL.


James : Wiki : Book : Blog : Twitter
Previous Topic:QueryHints BATCH / FETCH problems
Next Topic:CacheRetrieveMode.BYPASS of EclipseLink is not useful.
Goto Forum:
  


Current Time: Fri Apr 26 11:39:45 GMT 2024

Powered by FUDForum. Page generated in 0.03037 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top