This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Join Table many-to-one issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Join Table many-to-one issue" Watch "Join Table many-to-one issue" New topic
Author

Join Table many-to-one issue

Harry Dhina
Greenhorn

Joined: May 11, 2005
Posts: 6
I posted this on the hibernate forum, but no help. Sorry for the repost.

I have 3 tables:



My main table is PTNT_DATA_MSRMNT_CLCTN & join table is PTNT_PRCTC_PRFMNC_YR. I want to join these 2 tables by a non-primary key in the main table (PTNT_PRCTC_PRFMNC_YR_ID), but this does not work.

Hibernate Mapping:



The Hibernate generated SQL is:

where ptntdata.PTNT_DATA_MSRMNT_CLCTN_ID=prfmncyr.PTNT_PRCTC_PRFMNC_YR_ID.

But It should rather be
ptntdata.PTNT_PRCTC_PRFMNC_YR_ID=prfmncyr.PTNT_PRCTC_PRFMNC_YR_ID.


Hibernate version : 3.2.7.ga

Can you guys help me on this. Hope my question is clear & understandable
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Join Table many-to-one issue
 
Similar Threads
Hibernate- one-to-many association on a foreign key
Hibernate generating queries with duplicate columns
1-to-M mapping confusion
many-to-one relationship to non-PK field
many side of one to many not being populated