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 MacDonald
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 Sutherland
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:ORA-24816 on insert with LOB
Goto Forum:
  


Current Time: Thu Oct 02 14:39:46 GMT 2014

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

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