-->
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: Without Mappings....HQL INNER JOIN does not work
PostPosted: Wed Jun 22, 2005 5:33 am 
Newbie

Joined: Wed Jun 22, 2005 4:57 am
Posts: 3
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 305

SQL Query :

SELECT COUNT(T4.id) FROM TABLE4 T4 INNER JOIN TABLE3 T3 ON T4.id = T3.T4_id INNER JOIN TABLE2 T2 ON T3.id = T2.T3_id INNER JOIN TABLE1 T1 ON T2.T1_id = T1.id WHERE T1.type = 'My_TYPE' AND T1.id != 1001 AND TMOP.name = 'MY_NAME'


I have the above mentioned SQL query that is a join between 4 tables in the database. I had converted the same into HQL and wanted to use it in the application, but it throws the following error :

unexpected token: ON near line 1, column 158 [SELECT COUNT(C4.id) FROM CLASS4 C4 INNER JOIN CLASS3 C3 ON C4.id = C3.C4.id INNER JOIN CLASS2 C2 ON C3.id = C2.C3.id INNER JOIN CLASS1 C1 ON C2.C1.id = C1.id WHERE C1.type = 2 AND C1.id != 1001 AND C4.name = 'MYNAME']


The reason it threw this error is because of the ON clause present in the query. While going deeper into the issue, I realised that for JOINS, Hibernate doesn't require the ON clause in the query, and it automatically picks it up from the hibernate mappings file.

For some reasons, we have not given the relationship between the tables in the Hibernate Mappings (.hbm.xml ) files. Due to which the above HQL query doesn't work.

Can any one help us with this? Why doesn't Hibernate accepts the ON clause that is provided in the HQL query and it always needs to pick it up from the Hibernate mappings file? Why not pick by default the ON clause provided in the HQL query, if any. If not, then pick it up from the mappings file.

Thanks a ton,
Amit Chhajed


Top
 Profile  
 
 Post subject: I figured out....HHH-16
PostPosted: Thu Jun 23, 2005 12:20 am 
Newbie

Joined: Wed Jun 22, 2005 4:57 am
Posts: 3
I figured out the issue and it seems that it is been looked as a new feature to be implemented. We will have to wait and see in which version will this issue be resolved. For more details see http://opensource.atlassian.com/project ... wse/HHH-16

Regards,
Amit Chhajed


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.