wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes JPA: Joined Table ID of subclass Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JPA: Joined Table ID of subclass" Watch "JPA: Joined Table ID of subclass" New topic
Author

JPA: Joined Table ID of subclass

Frankie Fuentes
Ranch Hand

Joined: Mar 28, 2010
Posts: 41
Hi everyone,

How do I override the column name of the ID of my subclass entity? Say the superclass Parent is mapped to table "parent" and its id is mapped to column "id", then I have this subclass called Child mapped to table "child" having its id mapped to column "id". I want my subclass Child to get its id mapped to column "child_id" instead. Is this even possible? Is it defined in the JPA spec? I've been reading and scanning the spec and I can't seem to find it there or probably I'm must missing it.

Using AttributeOverride(s) has no effect at all.

Thanks!
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
You use @PrimaryKeyJoinColumn for this.



TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
Frankie Fuentes
Ranch Hand

Joined: Mar 28, 2010
Posts: 41
Thanks! That solved it
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JPA: Joined Table ID of subclass