-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: JPA multiple tables with foreign key from source to target
PostPosted: Thu Sep 06, 2007 10:50 am 
Newbie

Joined: Thu Sep 06, 2007 10:42 am
Posts: 1
Hello,
I am using JPA and trying to map a complex class to table mapping.

The simplified version is consider EMP and ADD tables where EMP has an ID primary key and has a foreign key ADD_ID to ADD. I need to map both tables to a single Employee class using JPA (I know I could just define two classes, but I cannot do this in my case).
If I just define EMP using @Table and ADD using @SecondaryTable, this does not work because it assumes ID is in ADD and matches EMP.ID, which it does not. Using @JoinColumn does not work either because I need to join with the foreign key not the primary key of EMP.
I seems that JPA does not support this, is there a Hibernate extension annotation that will allow this?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 06, 2007 8:26 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I don't think we support that. But usually, when a DBA use such a design, there is a reason to split the EMP object from the Add object, so an association is almost always a good thing to do.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.