This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan 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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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
Hibernate - Using subclass and joined-subclass element
can you have one-to-many join without using identifier column?
Mapping Question
Bind a whole class in jsp?
JPA, one to many and serialization