-->
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.  [ 1 post ] 
Author Message
 Post subject: Foreign key to primary key one-to-one join
PostPosted: Thu Feb 15, 2007 7:14 pm 
Newbie

Joined: Fri Feb 09, 2007 1:47 pm
Posts: 4
Hey folks I've been searching everywhere trying to find an answer to this problem to no avail so i throw myself at your mercy. I am trying to get a pretty simple join to work and am finding it surprisingly difficult. Here is a rough outline of what i'm trying to do:
Code:
MasterData:
Primary Key pk
Foreign Key fk

Branch1:
Primary Key pk

Branch2:
Primary Key pk


I'm basically just trying to collect data from these 3 tables like so:

Code:
select MasterData..., Branch1..., Branch2... from MasterData, Branch1, Branch2
where MasterData.pk = Branch1.pk
and MasterData.fk = Branch2.pk


I got the primary key to primary key join to work fine with a simple one-to-one element. I cannot get the foreign key to primary key to work at all though. I've tried one to one elements that look like:

Code:
<one-to-one
         name="branch2"
         class="Branch2"
         fetch="join"
         formula="fk"
      />


But i think i am using formula wrong. How can i tell hibernate to join the foreign key of the master table to the primary key of the associated table? I can't seem to find an example in the docs that does this. I have also tried many to one unique=true associations with no more luck.

EDIT: I'm using Hibernate3

Any help would be greatly appreciated.
Chris


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

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.