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