File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Object Relational Mapping
Join Table many-to-one issue
Joined: May 11, 2005
Jun 30, 2010 11:42:50
I posted this on the hibernate forum, but no help. Sorry for the repost.
I have 3 tables:
PTNT_DATA_MSRMT_CLCTN : PTNT_DATA_MSRMNT_CLCTN_ID (PK) PTNT_PRCTC_PRFMNC_YR_ID DEMO_PRCTC_DATA_CLCTN_PRD_ID PTNT_PRCTC_PRFMNC_YR: PTNT_PRCTC_PRFMNC_YR_ID (PK) DEMO_PRCTC_ID DEMO_PRFMNC_YR_ID PTNT_ID PTNT: PTNT_ID (PK) PTNT_TYPE_CD PTNT_EFCTV_DT PTNT_TRMNTN_DT
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.
<class name="PatientDataMeasurementCollection" table="PTNT_DATA_MSRMNT_CLCTN"> <id name="patientDataMeasurementCollectionId" column="PTNT_DATA_MSRMNT_CLCTN_ID" type="long"> <generator class="assigned" /> </id> <property name="demoCollectionPeriodId" column="DEMO_PRCTC_DATA_CLCTN_PRD_ID" type="long" /> <property name="patientPracticePerformanceYearId" column="PTNT_PRCTC_PRFMNC_YR_ID" type="long" /> <join table="PTNT_PRCTC_PRFMNC_YR" optional="false"> <key column="PTNT_PRCTC_PRFMNC_YR_ID" unique="true" property-ref="patientPracticePerformanceYearId" /> <many-to-one name="patient" column="PTNT_ID" not-null="true" fetch="join" /> </join> </class>
The Hibernate generated SQL is:
But It should rather be
Hibernate version : 3.2.7.ga
Can you guys help me on this. Hope my question is clear & understandable
I agree. Here's the link:
subject: Join Table many-to-one issue
Hibernate- one-to-many association on a foreign key
many-to-one relationship to non-PK field
many side of one to many not being populated
1-to-M mapping confusion
Hibernate generating queries with duplicate columns
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015