-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: If not <join><key property-ref></join>, th
PostPosted: Wed Oct 26, 2005 9:53 am 
Newbie

Joined: Mon Feb 28, 2005 5:46 pm
Posts: 7
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:
NONCONFORMANCE
NONCONFORMANCE_SYSID - PK
NCM_SOURCE

NCM_SOURCE
NCM_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


Top
 Profile  
 
 Post subject: my solution
PostPosted: Wed Oct 26, 2005 11:35 am 
Newbie

Joined: Mon Feb 28, 2005 5:46 pm
Posts: 7
Apparently I was reading one of the work-around solutions incorrectly. I was trying to place a formula on my join's property element when I should have just replaced the whole join with a property tag utilizing a formula attribute (duh... enough coffee today?)

Given that you can utilize a formula for a property, why would you ever use the join tag? My guess is that it does (at least) 2 things when you require more than one column from an outside table:
    1) Reduces the number of select/joins to the database, thereby improving efficiency.
    2) Conveniently groups items in your mapping all while reducing otherwise redundant formula code

...but I'm really not sure, thus I'm wondering what other more experienced users think about this.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.