-->
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.  [ 3 posts ] 
Author Message
 Post subject: HQL Joining with non-primary key columns
PostPosted: Thu Nov 10, 2005 12:12 pm 
Newbie

Joined: Wed Oct 05, 2005 4:51 am
Posts: 3
Location: Cardiff
Hi, I have the following HQL
FROM Object1 obj1
INNER JOIN obj1.set1 set1
INNER JOIN obj1.eqTextTs set2
WHERE (obj1.hideQuestion = 0)
AND (set1.id = :policy)
AND (obj1.secondId = 0)
AND (set1.comp_id.id = :id
OR set1.comp_id.id = - 1)
ORDER BY obj1.num

The relationship refered to as set1 is joing to obj1 with its primary key, how ever this is not what I want, I'd like obj1 to join to set1 using a different column and not its primary key column.
My hbm.xml files contain the correct colum references but when I view the sql hibernate is producing for this query it still trys to join using obj1's primary key.
Is it possible to join to a column that isn't the primary key in hibernate if so how is it achieved?


Thanks,


Si


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 3:07 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
AFAIK you can join only on relations defined by the hbm.xml file. In order to get your join working you can map this extra relation in your hbm.xml file.

HTH
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 4:41 am 
Newbie

Joined: Wed Oct 05, 2005 4:51 am
Posts: 3
Location: Cardiff
Hi, I have this relationship defined my hbm.xml files.

Here is an extract to show the relationship
This would be in object1.hbm.xml
<set
name="eqTextTs"
lazy="true"
inverse="true"
cascade="none"

>
<key>
<column name="EQ_Text_ID" />
</key>
<one-to-many
class="com.epitiro.xbroker.questions.model.EqTextT"
/>
</set>

Here is the relationship back to object1

<many-to-one
name="object1"
class="com.epitiro.xbroker.questions.model.EnquiryQuestionsLu"
update="false"
insert="false"
>
<column name="EQ_Text_ID" />
</many-to-one>

Unfortunately my join is still acting tring top joing the key of object1 to the eq_text_id of eq_text.


Thanks,


Si


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.