This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPA: Joined Table ID of subclass
 
Similar Threads
can you have one-to-many join without using identifier column?
Bind a whole class in jsp?
JPA, one to many and serialization
Mapping Question
Hibernate - Using subclass and joined-subclass element