File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA: Joined Table ID of subclass

 
Frankie Fuentes
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 553
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You use @PrimaryKeyJoinColumn for this.


 
Frankie Fuentes
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! That solved it
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic