-->
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.  [ 3 posts ] 
Author Message
 Post subject: Unsure on mapping -null foreign keys - simple question
PostPosted: Mon Jan 16, 2006 12:07 pm 
Regular
Regular

Joined: Fri Nov 04, 2005 12:37 pm
Posts: 81
I have two tables Employer and OldEmployer. The employer table has a column old_id that is a foreign key to OldEmployer.Id. But not every Employer has a corresponding record in OldEmployer so old_id is sometimes null.



I need a one to one mapping between these two tables where the foreign key is sometimes null. How do i do this?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 17, 2006 5:17 am 
Regular
Regular

Joined: Mon Jul 18, 2005 4:10 am
Posts: 92
Location: Poland
Use the "OldEmployee" property at the "Employee" side and map it as <many-to-one name="OldEmployee" column="old_id" class="OldEmployer"> (not one-to-one!).
On the old one side use <one-to-one name="CurrentEmployee" class="Emplayee" property-ref="OldEmployer"> (no extra column at the old one side - PK is used)

_________________
michal


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 17, 2006 6:14 am 
Regular
Regular

Joined: Fri Nov 04, 2005 12:37 pm
Posts: 81
thx


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.