Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
I'm mapping a "<join table=.." to a mapping file, however the primary key is not the foreign key in the table I'm joining to. I have read the following 2 posts regarding property-ref not being implemented.
http://forum.hibernate.org/viewtopic.php?t=942397&highlight=propertyref+join+table
http://forum.hibernate.org/viewtopic.php?t=937111
Is there a recommended work-around for property-ref?
I've perused the documentation, but haven't quite found what I'm looking for. It was stated that property-ref is not yet implemented and not anywhere in the documentation, however the documentation has the following:
Code:
<key
column="columnname" (1)
on-delete="noaction|cascade" (2)
property-ref="propertyName" (3)
not-null="true|false" (4)
update="true|false" (5)
unique="true|false" (6)
/>
Was it implemented and I'm just missing something?...
My DB tables are as follows:
NONCONFORMANCENONCONFORMANCE_SYSID - PK
NCM_SOURCE
NCM_SOURCENCM_SOURCE - PK
DESCRIPTION
Hibernate version: 3.0.5
Mapping documents:Relevant mapping
Code:
<class name="Nonconformance" table="NONCONFORMANCE" optimistic-lock="none" where="PUBLIC_FLAG='Y'">
<id name="nonconformanceSysid" column="NONCONFORMANCE_SYSID" type="java.lang.String">
<generator class="assigned"/>
</id>
<property name="ncmSource" column="NCM_SOURCE" type="java.lang.String"/>
...
<join table="NCM_SOURCE" inverse="true" fetch="join">
<key column="NCM_SOURCE" property-ref="ncmSource"/>
<property name="ncmSourceDesc" column="DESCRIPTION" type="java.lang.String"/>
</join>
</class>
Full stack trace of any exception that occurs:
No exceptions
Name and version of the database you are using:
SQL Server 7
The generated SQL (show_sql=true):
relevant SQL output:
left outer join NCM_SOURCE nonconform1_1_ on nonconform1_.NONCONFORMANCE_SYSID=nonconform1_1_.NCM_SOURCE
I need to get
nonconform1_.NCM_SOURCE=nonconform1_1_.NCM_SOURCE