-->
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.  [ 4 posts ] 
Author Message
 Post subject: Left Join
PostPosted: Thu Sep 07, 2006 10:05 am 
Newbie

Joined: Mon Jul 11, 2005 12:33 am
Posts: 2
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3

HQL as I 've done
FROM PMSProjectsORO pjt LEFT JOIN PMSChecklistORO pcl ON pjt.projectId = pcl.projectId order by pjt.projectCode asc

Original SQL for MSQL5:
FROM PMSProject LEFT JOIN PMSCheckList ON
PMSProject.PROJECT_ID = PMSCheckList.PROJECT_ID order by PMSProject.PROJECT_CODE desc
Name and version of the database you are using:
MYSQL 5

Please help me convert the sql to hql since what i 've done is throwing error like unexpected token... Please reply ASAP


Read this: http://hibernate.org/42.html

_________________
j.i.t.h.e.s.h


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 07, 2006 10:08 am 
Senior
Senior

Joined: Wed Aug 17, 2005 12:56 pm
Posts: 136
Location: Erie, PA (USA)
There is no "ON ..." syntax in HQL -- the association is defined in the Hibernate mapping files.

So, HQL would be something like
Code:
FROM PMSProjectsORO pjt LEFT JOIN PMSChecklistORO pcl ORDER BY pjt.projectCode ASC

_________________
---- Don't forget to rate! ----


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 07, 2006 10:24 am 
Newbie

Joined: Mon Jul 11, 2005 12:33 am
Posts: 2
No mapping is done between these tables... I need to know how can we acheive the same with out a mapping defined. ie it should completely come from HQL...

Still i've tried the same what u 've suggested... but gave an error:

org.hibernate.hql.ast.QuerySyntaxException: Path expected for join!

Please help me resolve this..

_________________
j.i.t.h.e.s.h


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 07, 2006 10:36 am 
Senior
Senior

Joined: Wed Aug 17, 2005 12:56 pm
Posts: 136
Location: Erie, PA (USA)
SORRY, this will only get you an inner join.

You need mappings to use HQL. If you have mappings but no relationship, you can use the syntax of:
Code:
FROM Object1 obj1, Object2 obj2 WHERE obj1.prop1 = obj2.prop2
to acheive a "join".

You could use native SQL within Hibernate.

Curtis ...

_________________
---- Don't forget to rate! ----


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