Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Foreign key to primary key one-to-one join

Chris Car
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

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

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:

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.
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!