-->
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.  [ 9 posts ] 
Author Message
 Post subject: a simple Hql ,but it throw error
PostPosted: Tue Sep 02, 2003 10:08 am 
Newbie

Joined: Thu Aug 28, 2003 11:19 pm
Posts: 17
i am write a simple hql

select topic,prop1,prop2 from Topic as topic
left outer join Property as prop1 on topic.topicId=prop1.itemRef
left outer join Property as prop2 on topic.topicId=prop2.itemRef
where topic.tracker=0


but it throw a error

outer or full join must be followed by path expression [select topic,prop1,prop2 from com.beaconsystem.catseye3.hibs.Topic as topic left outer join Property as prop1 on topic.topicId=prop1.itemRefleft outer join Property as prop2 on topic.topicId=prop2.itemRef]
at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:526)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:467)


what does it mean? what's wrong with it


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 02, 2003 10:11 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
All HQL property references MUST be qualified by an alias. ie. it is ALWAYS "foo.bar", never just "bar".

If you look at the examples in the Hibernate documentation, they are all like that.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 02, 2003 10:12 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Oh, and also HQL has no ON clause in an OUTER JOIN.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 02, 2003 10:22 am 
Newbie

Joined: Thu Aug 28, 2003 11:19 pm
Posts: 17
oh here Property is class

that is to say

i should write it

left out join topic.property as prop1

is it

if no on clause
,how hibernate know class topic and class property join on topic.topicId=prop1.itemRef

here Topic and Property is absolute


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 02, 2003 10:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Quote:
how hibernate know class topic and class property join on topic.topicId=prop1.itemRef

That would be the purpose of mapping a relationship between them...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 02, 2003 10:34 am 
Newbie

Joined: Thu Aug 28, 2003 11:19 pm
Posts: 17
oh that is to say if i want use outer join ,i must map the relation of the in the map file,is it? otherwise i only use where clause


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 02, 2003 11:00 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
I am not certain whether old-style SQL joins are fully avaiable or not for use in HQL. Defintely, you could do inner joins there pretty easily just by using = between the two join properties. Outer joins were always more difficult mainly due to the fact that there was really no standard way to notate it. Actually, there was using the *= syntax, but some big DB vendors (you know who you are Oracle_) decided that there propietray syntax was better and refused to adapt to the standard.

Personally, I would say that if you need to query against a relationship or to navigate across it to go ahead and map the relationship in Hibernate. The performace is actually very good with judicious use of lazy collection and proxies...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 02, 2003 11:24 am 
Newbie

Joined: Thu Aug 28, 2003 11:19 pm
Posts: 17
ok thanks

now

in database

table topic

topicid topic_title
38 hql_test

table Property
propertyid item_ref item_name item_value
15 38 appendString invocation
16 38 appendFloat 99.9



my hql:

select topic,prop1,prop2 from Topic as topic,Property as prop1,Property as prop2
where topic.topicId=prop1.itemRef and topic.topicId=prop2.itemRef



show result:
topicid topic_title item_value
38 hql_test invocation invocation
38 hql_test invocation 99.9
38 hql_test 99.9 invocation
38 hql_test 99.9 99.9


but i only want one
38 hql_test invocation 99.9

why return four ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 02, 2003 11:37 am 
Newbie

Joined: Thu Aug 28, 2003 11:19 pm
Posts: 17
i think i resolve it

thanks :)


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