Skip to main content



      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 13:45 Go to next message
Eclipse UserFriend
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 11:27 Go to previous message
Eclipse UserFriend
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.
Previous Topic:QueryHints BATCH / FETCH problems
Next Topic:CacheRetrieveMode.BYPASS of EclipseLink is not useful.
Goto Forum:
  


Current Time: Wed Jul 23 19:29:59 EDT 2025

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

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

Back to the top